//************************************************************************************************************************************************************* public static bool ResetQBPrefForCommentedReports(TestStack.White.Application qbApp, TestStack.White.UIItems.WindowItems.Window qbWindow) { try { qbAppWindowForSilk = _desktop.Window("/Window"); qbAppWindowForSilk.SetActive(); FrameworkLibraries.ActionLibs.WhiteAPI.Actions.SelectMenu(qbApp, qbWindow, "Edit", "Preferences..."); TestStack.White.UIItems.WindowItems.Window preferencesWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Preferences"); SilkTest.Ntf.Window prefWindowForSilk = qbAppWindowForSilk.Window("@caption='Preferences'"); prefWindowForSilk.TextClick("General", 1, ClickType.Left); Thread.Sleep(int.Parse(Execution_Speed)); FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(preferencesWindow, "Bring back all one time messages"); Thread.Sleep(int.Parse(Execution_Speed)); ////check if the checkbox is selected. If yes, uncheck it //FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(preferencesWindow, "Turn off pop-up messages for products and services"); //Thread.Sleep(int.Parse(Execution_Speed)); //check if the prompt me to modify report before opening a report is checked and uncheck it if needed prefWindowForSilk.TextClick("Desktop View", 1, ClickType.Left); Thread.Sleep(int.Parse(Execution_Speed)); if (FrameworkLibraries.ActionLibs.WhiteAPI.Actions.CheckWindowExists(qbWindow, "Save Changes")) { TestStack.White.UIItems.WindowItems.Window saveChangesWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Save Changes"); FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(saveChangesWindow, "Yes"); Thread.Sleep(int.Parse(Execution_Speed)); } FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(preferencesWindow, "Multiple Windows"); Thread.Sleep(int.Parse(Execution_Speed)); prefWindowForSilk.TextClick("Reports & Graphs", 1, ClickType.Left); Thread.Sleep(int.Parse(Execution_Speed)); if (FrameworkLibraries.ActionLibs.WhiteAPI.Actions.CheckWindowExists(qbWindow, "Save Changes")) { TestStack.White.UIItems.WindowItems.Window saveChangesWindow = FrameworkLibraries.ActionLibs.WhiteAPI.Actions.GetChildWindow(qbWindow, "Save Changes"); FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(saveChangesWindow, "Yes"); Thread.Sleep(int.Parse(Execution_Speed)); } ////check if collapse transFrameworkLibraries.ActionLibs.WhiteAPI.Actions is checked. If yes, uncheck it //prefWindowForSilk.TextClick("Company Preferences", 1, ClickType.Left); //Thread.Sleep(int.Parse(Execution_Speed)); //FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(preferencesWindow, "Collapse TransFrameworkLibraries.ActionLibs.WhiteAPI.Actions"); //Thread.Sleep(int.Parse(Execution_Speed)); FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(preferencesWindow, "OK"); Thread.Sleep(int.Parse(Execution_Speed)); Logger.logMessage(" QB Preferences have been set successfully"); Logger.logMessage("------------------------------------------------------------------------------"); return true; } catch (Exception e) { Logger.logMessage("ResetQBPrefForCommentedReports : -> Failed to save QB preferences for Commented report"); Logger.logMessage(e.Message); Logger.logMessage("------------------------------------------------------------------------------"); String sMessage = e.Message; LastException.SetLastError(sMessage); throw new Exception(sMessage); } }
//************************************************************************************************************************************************************** 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 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); } }
//************************************************************************************************************************************************************** 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 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); } }