//**************************************************************************************************************************************************************
        public static bool RenameCommentedReport(TestStack.White.Application qbApp, TestStack.White.UIItems.WindowItems.Window qbWindow, string currentReportName,string newReportName)
        {
            try
            {
                bool reportExist = Reports.CheckCommentedReportExists(qbApp, qbWindow, currentReportName);
                if (reportExist)
                {
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.SelectMenu(qbApp, qbWindow, "Reports", "Commented Reports");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    qbAppWindowForSilk = _desktop.Window("/Window");
                    qbAppWindowForSilk.SetActive();
                    commentedReportListWindowForSilk = qbAppWindowForSilk.Window("@caption='Commented Reports'");
                    commentedReportListWindowForSilk.Maximize();
                    commentedReportListWindowForSilk.TextClick(currentReportName, 1, ClickType.Left);
                    TestStack.White.UIItems.WindowItems.Window commentedReportListWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Commented Reports");
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(commentedReportListWindow, "Commented Reports");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.DesktopInstance_ClickElementByName("Edit Commented Report");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.SetTextByAutomationID(FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Save Your Commented Report"), "12402", newReportName);
                    if (FrameworkLibraries.ActionLibs.WhiteAPI.Actions.CheckWindowExists(qbWindow, "Replace Your Commented Report?"))
                    {
                        TestStack.White.UIItems.WindowItems.Window renameWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Replace Your Commented Report?");
                        FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(renameWindow, "Yes");
                        Thread.Sleep(int.Parse(Execution_Speed));
                    }
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Save Your Commented Report"), "OK");
                    Thread.Sleep(int.Parse(Execution_Speed));

                    //Check that the name is changed successfully
                    commentedReportListWindowForSilk.TextClick(newReportName, 1, ClickType.Left);

                    Logger.logMessage("RenameCommentedReport :  " + currentReportName + " has been Successfully renamed to " + newReportName);
                    Logger.logMessage("------------------------------------------------------------------------------");
                    return true;
                }
                else
                    Logger.logMessage("RenameCommentedReport :  ->" + currentReportName + " does not exist hence cannot cannot rename");
                    Logger.logMessage("------------------------------------------------------------------------------");
                    return false;
            }
            catch (Exception e)
            {
                Logger.logMessage("RenameCommentedReport :  " + currentReportName + " has not been renamed to " + newReportName);
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
 //**************************************************************************************************************************************************************
 public static bool DeleteCommentedReport(TestStack.White.Application qbApp, TestStack.White.UIItems.WindowItems.Window qbWindow, string reportNameToDelete)
 {
       try
          {
             //check if the report to be deleted exists
             bool reportExist = Reports.CheckCommentedReportExists(qbApp, qbWindow, reportNameToDelete);
             if (reportExist)
             {
                     FrameworkLibraries.ActionLibs.WhiteAPI.Actions.SelectMenu(qbApp, qbWindow, "Reports", "Commented Reports");
                     Thread.Sleep(int.Parse(Execution_Speed));
                     qbAppWindowForSilk = _desktop.Window("/Window");
                     qbAppWindowForSilk.SetActive();
                     commentedReportListWindowForSilk = qbAppWindowForSilk.Window("@caption='Commented Reports'");
                     commentedReportListWindowForSilk.Maximize();
                     commentedReportListWindowForSilk.TextClick(reportNameToDelete, 1, ClickType.Left);
                     TestStack.White.UIItems.WindowItems.Window commentedReportListWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Commented Reports");
                     FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(commentedReportListWindow, "Commented Reports");
                     Thread.Sleep(int.Parse(Execution_Speed));
                     FrameworkLibraries.ActionLibs.WhiteAPI.Actions.DesktopInstance_ClickElementByName("Delete Commented Report");
                     Thread.Sleep(int.Parse(Execution_Speed));
                     FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Delete This Commented Report?"), "Yes");
                     Thread.Sleep(3000);
                     try
                     {
                         bool deletedReportExist = Reports.CheckCommentedReportExists(qbApp, qbWindow, reportNameToDelete);
                     if (!deletedReportExist)
                     {
                         Logger.logMessage("DeleteCommentedReport -> Specified commented report " + reportNameToDelete + " was deleted successfully ");
                         Logger.logMessage("------------------------------------------------------------------------------");
                     }
                     else
                     {
                         Logger.logMessage("DeleteCommentedReport -> Failed to delete " + reportNameToDelete);
                         Logger.logMessage("------------------------------------------------------------------------------");
                     }
                   }
                   catch (Exception e) { }
           }
             Logger.logMessage("SaveCommentedReport " + " -> Save commented report for " + reportNameToDelete + " successful");
             Logger.logMessage("------------------------------------------------------------------------------");
             return true;
       }
       catch (Exception e)
         {
             Logger.logMessage("SaveCommentedReport " + " -> Save commented report for " + reportNameToDelete + " failed");
             Logger.logMessage(e.Message);
             Logger.logMessage("------------------------------------------------------------------------------");
             String sMessage = e.Message;
             LastException.SetLastError(sMessage);
             throw new Exception(sMessage);
         }
 }
        //**************************************************************************************************************************************************************
        public static bool CheckCommentedReportExists(TestStack.White.Application qbApp, TestStack.White.UIItems.WindowItems.Window qbWindow, string reportNameToCheck)
        {
            Logger.logMessage("In check commented report exists loop");
            try
            {
               
                //check if its a new report creation or updating existing commented report
                try
                {
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.SelectMenu(qbApp, qbWindow, "Reports", "Commented Reports");
                }
                catch { }
                Thread.Sleep(int.Parse(Execution_Speed));

                //qbAppWindowForSilk = _desktop.Window("/Window");
                //qbAppWindowForSilk.SetActive();
                commentedReportListWindowForSilk = _desktop.Window("@caption='Commented Reports'");
                commentedReportListWindowForSilk.Maximize();
                try
                {
                    commentedReportListWindowForSilk.TextClick(reportNameToCheck, 1, ClickType.Left);
                }
                catch (Exception e) { return false; }
                Logger.logMessage("CheckCommentedReportExists " + " -> " + reportNameToCheck + " exists");
                Logger.logMessage("------------------------------------------------------------------------------");
                return true;
            }
            catch (Exception e)
            {
                Logger.logMessage("CheckCommentedReportExists " + " -> " + reportNameToCheck + " does not exist");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
 //**************************************************************************************************************************************************************
 public static bool OpenSavedCommentedReport(TestStack.White.Application qbApp, TestStack.White.UIItems.WindowItems.Window qbWindow, string reportNameToOpen, string commentedReportTitle)
 {
     Logger.logMessage("In Open Saved commented loop");
     try
     {
         bool reportExist = Reports.CheckCommentedReportExists(qbApp, qbWindow, reportNameToOpen);
         if (reportExist)
         {
             qbAppWindowForSilk = _desktop.Window("/Window");
             qbAppWindowForSilk.SetActive();
             commentedReportListWindowForSilk = qbAppWindowForSilk.Window("@caption='Commented Reports'");
             commentedReportListWindowForSilk.TextClick(reportNameToOpen, 1, ClickType.Left);
             //Open the saved commented report
            try
             {
                 FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Commented Reports"), "Display...");
            }
            catch{}
             try{
                 FrameworkLibraries.ActionLibs.WhiteAPI.Actions.WaitForChildWindow(qbWindow, commentedReportTitle, int.Parse(Sync_Timeout));
             }
             catch (Exception e) { }
             Logger.logMessage("OpenSavedCommentedReport " + " -> " + reportNameToOpen + " was opened successfully");
             Logger.logMessage("------------------------------------------------------------------------------");
             return true;
         }
         else
             Logger.logMessage("OpenSavedCommentedReport " + " -> cannot open " + reportNameToOpen);
             Logger.logMessage("------------------------------------------------------------------------------");
             return false;
     }
     catch (Exception e)
     {
         Logger.logMessage("OpenSavedCommentedReport " + " -> cannot open "+ reportNameToOpen );
         Logger.logMessage(e.Message);
         Logger.logMessage("------------------------------------------------------------------------------");
         String sMessage = e.Message;
         LastException.SetLastError(sMessage);
         throw new Exception(sMessage);
     }
 }
Exemplo n.º 5
0
        //*************************************************************************************************************************************************************
        public static bool DeleteCommentedRepertWhichIsInUse(TestStack.White.Application qbApp, TestStack.White.UIItems.WindowItems.Window qbWindow, ReportData reportData)
        {
            Logger.logMessage("DeleteCommentedRepertWhichIsInUse : -> Started");
            Logger.logMessage("------------------------------------------------------------------------------");
            try
            {
                bool res = false;
                QuickBooks.ResetQBWindows(qbApp, qbWindow, false);
                res = Reports.CreateCommentedReport(qbApp, qbWindow, reportData.reportName, reportData.accesspoint, reportData.defaultReportTitle, reportData.fromDate, reportData.toDate, "noncustom", reportData.commentedReportName, reportData.defaultCommentedReportTitle);
                Assert.AreEqual(true, res, "Create commented report failed for " + reportName);
                QuickBooks.ResetQBWindows(qbApp, qbWindow, false);
               
                //Open saved Commented report
                Reports.OpenSavedCommentedReport(qbApp, qbWindow, reportData.commentedReportName, reportData.commentedReportTitle);

                    qbAppWindowForSilk = _desktop.Window("/Window");
                    qbAppWindowForSilk.SetActive();
                    commentedReportListWindowForSilk = qbAppWindowForSilk.Window("@caption='Commented Reports'");
                    commentedReportListWindowForSilk.Maximize();
                    commentedReportListWindowForSilk.TextClick(reportData.commentedReportName, 1, ClickType.Left);
                    TestStack.White.UIItems.WindowItems.Window commentedReportListWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Commented Reports");
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(commentedReportListWindow, "Commented Reports");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.DesktopInstance_ClickElementByName("Delete Commented Report");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Delete This Commented Report?"), "Yes");
                try{
                if(Actions.CheckWindowExists(qbWindow,"Warning"))
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow,"Warning"),"OK");
                }catch{}
                QuickBooks.ResetQBWindows(qbApp, qbWindow, false);


                Logger.logMessage("DeleteCommentedRepertWhichIsInUse : -> Succeeded");
                Logger.logMessage("------------------------------------------------------------------------------");
                return true;
            }
            catch (Exception e)
            {
                Logger.logMessage("DeleteCommentedRepertWhichIsInUse : -> Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }