Ejemplo n.º 1
0
        //**************************************************************************************************************************************************************
        public static bool CheckWindowExists(Window mainWindow, string childWindowName)
        {
            bool window = false;

            try
            {
                List<Window> allChildWindows = mainWindow.ModalWindows();

                foreach (Window w in allChildWindows)
                {
                    if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
                    {
                        window = true;
                        Thread.Sleep(int.Parse(Execution_Speed));
                        break;
                    }
                }

                return window;
            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 2
0
        //**************************************************************************************************************************************************************
        public static void ResetQBWindows(TestStack.White.Application qbApp, Window qbWin)
        {
            List<Window> modalWin = null;
            int iteration = 0;

            try
            {
                do
                {
                    if (iteration <= 10)
                    {
                        iteration = iteration + 1;
                        modalWin = qbWin.ModalWindows();

                        foreach (Window item in modalWin)
                        {
                            //Alert window handler
                            try
                            {
                                Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "OK");
                                Thread.Sleep(int.Parse(ResetWindow_Timeout));
                            }
                            catch (Exception) { }

                            try
                            {
                                Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "No");
                                Thread.Sleep(int.Parse(ResetWindow_Timeout));
                            }
                            catch (Exception) { }

                            //Register QB window handler
                            if (item.Name.Contains("Register QuickBooks"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Remind Me Later");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //No company window handler
                            else if (item.Name.Contains("No"))
                            {
                                try
                                {
                                    QuickBooks.OpenOrUpgradeCompanyFile(DefaultCompanyFilePath, qbApp, qbWin, false, false);
                                }
                                catch { }
                            }

                            //Update quickbooks window handler
                            else if (item.Name.Contains("Update QuickBooks"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Close");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Payroll update window handler
                            else if (item.Name.Equals("Payroll Update"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Cancel");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }

                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }

                            }

                            //Intuit payroll services window hadler
                            else if (item.Name.Contains("Intuit Payroll Services"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Employer services window handler
                            else if (item.Name.Contains("Employer Services"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Cancel");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Insights works on the accrual basis window handler
                            else if (item.Name.Equals("Insights works on the accrual basis only"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Insights works on the accrual basis window handler
                            else if (item.Name.Contains("Insights"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Enter memorized transactions window handler
                            else if (item.Name.Contains("Enter Memorized Transactions"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWin, "Enter Memorized Transactions"), "Enter All Later");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWin, "Enter Memorized Transactions"), "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Recording transaction window handler
                            else if (item.Name.Contains("Recording Transaction"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "No");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Login window handler
                            else if (item.Name.Equals("QuickBooks Login"))
                            {
                                Actions.SetFocusOnWindow(item);
                                Actions.SendBCKSPACEToWindow(item);
                                Actions.SetTextByAutomationID(item, "15922", UserName);
                                Actions.SendTABToWindow(item);
                                Actions.SendKeysToWindow(item, Password);
                                Actions.ClickElementByAutomationID(item, "51");
                                Actions.WaitForAnyChildWindow(qbWin, "QuickBooks Login", int.Parse(Sync_Timeout));
                                Thread.Sleep(int.Parse(ResetWindow_Timeout));
                            }

                            //Error window handler
                            else if (item.Name.Contains("Error"))
                            {
                                Actions.ClickElementByName(item, "Don't Send");
                                Thread.Sleep(int.Parse(ResetWindow_Timeout));
                            }

                            //QB Setup window handler
                            else if (item.Name.Contains("Setup"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Close");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch (Exception)
                                { }

                                try
                                {
                                    Actions.ClickElementByName(item, "Yes");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch (Exception)
                                { }

                            }

                            //Warning window handler
                            else if (item.Name.Contains("Warning"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch (Exception)
                                { }
                            }

                            else
                            {
                                item.Focus();

                                try { Actions.ClickElementByName(Actions.GetChildWindow(qbWin, "Recording Transaction"), "No"); }
                                catch { }

                                try
                                {
                                    Actions.ClickElementByName(item, "Close");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }

                                try
                                {
                                    item.Close();
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }

                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }
                        }
                        Thread.Sleep(int.Parse(ResetWindow_Timeout));

                        try
                        {
                            Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "OK");
                            Thread.Sleep(int.Parse(ResetWindow_Timeout));
                        }
                        catch (Exception) { }

                        try
                        {
                            Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "No");
                            Thread.Sleep(int.Parse(ResetWindow_Timeout));
                        }
                        catch (Exception) { }

                        Thread.Sleep(int.Parse(Execution_Speed));
                    }
                    else
                    {
                        break;
                    }
                }
                while (modalWin.Count != 0);
                Thread.Sleep(int.Parse(Execution_Speed));
            }

            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 3
0
        //**************************************************************************************************************************************************************
        public static void OpenOrUpgradeCompanyFile(string companyFilePath, TestStack.White.Application qbApp, Window qbWindow, bool backupcopy, bool portalcopy)
        {
            try
            {
                Actions.SelectMenu(qbApp, qbWindow, "File", "Open or Restore Company...");
                Thread.Sleep(int.Parse(Execution_Speed));

                if (backupcopy)
                {
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Restore a backup copy");
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Local backup");
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
                    Thread.Sleep(int.Parse(Execution_Speed));

                    try
                    {
                        Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Open Backup Copy"), "File name:", companyFilePath);
                        Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open Backup Copy"), "Open");
                        Actions.WaitForChildWindow(qbWindow, "Open or Restore Company", int.Parse(Sync_Timeout));
                    }
                    catch (Exception) { }

                    try
                    {
                        Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
                        Thread.Sleep(int.Parse(Execution_Speed));
                    }
                    catch (Exception) { }

                    try
                    {
                        Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "File name:", Utils.StringFunctions.RandomString(5));
                        Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "Save");
                        Actions.WaitForAnyChildWindow(qbWindow, "Save Company File as", int.Parse(Sync_Timeout));
                    }
                    catch (Exception) { }

                }
                else if (portalcopy)
                {
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Restore a portable file");
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
                    Thread.Sleep(int.Parse(Execution_Speed));

                    try
                    {
                        Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Open Portable Company File"), "File name:", companyFilePath);
                        Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open Portable Company File"), "Open");
                        Actions.WaitForChildWindow(qbWindow, "Open or Restore Company", int.Parse(Sync_Timeout));
                    }
                    catch (Exception) { }

                    try
                    {
                        Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
                        Thread.Sleep(int.Parse(Execution_Speed));
                    }
                    catch (Exception) { }

                    try
                    {
                        Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "File name:", Utils.StringFunctions.RandomString(5));
                        Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Save Company File as"), "Save");
                        Actions.WaitForAnyChildWindow(qbWindow, "Save Company File as", int.Parse(Sync_Timeout));
                    }
                    catch (Exception) { }

                }
                else
                {
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Open a company file");
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open or Restore Company"), "Next");
                    Thread.Sleep(int.Parse(Execution_Speed));
                    Actions.SetTextOnElementByName(Actions.GetChildWindow(qbWindow, "Open a Company"), "File name:", companyFilePath);
                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Open a Company"), "Open");
                    Actions.WaitForAnyChildWindow(qbWindow, "Open a Company", int.Parse(Sync_Timeout));
                }

                List<Window> modalWin = null;
                int iteration = 0;

                do
                {
                    modalWin = qbWindow.ModalWindows();
                    iteration = iteration + 1;

                    if (iteration <= 7)
                    {
                        foreach (Window item in modalWin)
                        {

                            //QB Login window handler
                            if (item.Name.Contains("QuickBooks Login"))
                            {
                                try
                                {
                                    Actions.SetFocusOnWindow(item);
                                    Actions.SendBCKSPACEToWindow(item);
                                    Actions.SetTextByAutomationID(item, "15922", UserName);
                                    Actions.SendTABToWindow(item);
                                    Actions.SendKeysToWindow(item, Password);
                                    Actions.ClickElementByAutomationID(item, "51");
                                    Actions.WaitForAnyChildWindow(qbWindow, "QuickBooks Login", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //Register quickbooks window handler
                            else if (item.Name.Contains("Register QuickBooks"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Remind Me Later");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }
                                catch { }
                            }

                            //Update to new version window handler - I agree
                            else if (item.Name.Contains("Update Company File for New Version") || item.Name.Contains("Update Company File to New Version"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "I understand that my company file will be updated to this new version of QuickBooks.");
                                }
                                catch (Exception) { }
                                try
                                {
                                    Actions.ClickElementByName(item, "Update Now");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Update Company File", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //QB Backup
                            else if (item.Name.Contains("QuickBooks Backup"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Actions.WaitForChildWindow(qbWindow, "Backup", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Backup"), "Yes");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Backup", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Backup Incompatible"), "OK");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch (Exception) { }

                            }

                            //Backup incompatible window handler
                            else if (item.Name.Contains("Backup Incompatible"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                }
                                catch (Exception) { }
                            }

                            //Sync company file window handler
                            else if (item.Name.Contains("Sync Company File"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Continue");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Sync Company File", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //QB Information window handler
                            else if (item.Name.Contains("QuickBooks Information"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Actions.WaitForAnyChildWindow(qbWindow, "QuickBooks Information", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //Create backup copy window handler
                            else if (item.Name.Contains("Create Backup"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Next");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch (Exception) { }
                            }

                            //Backup options window handler - file path
                            else if (item.Name.Equals("Backup Options"))
                            {
                                try
                                {
                                    Actions.SetTextByAutomationID(item, "2002", TestDataLocalDirectory);
                                }

                                catch (Exception) { }
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "QuickBooks"), "Use this Location");
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Save Backup Copy"), "Save");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Save Backup Copy", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //Quickbooks use this location window handler
                            else if (item.Name.Contains("QuickBooks"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "QuickBooks"), "Use this Location");
                                    Actions.WaitForAnyChildWindow(qbWindow, "QuickBooks", int.Parse(Sync_Timeout));
                                }
                                catch(Exception)
                                {
                                }
                            }

                            //Save backup copy window handler
                            else if (item.Name.Contains("Save Backup Copy"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Save Backup Copy"), "Save");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Save Backup Copy", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Update Company"), "Yes");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Update Company", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //Update company window handler
                            else if (item.Name.Contains("Update Company"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Yes");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Update Company", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(item, "Continue");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Update Company", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //Enter email address window handler
                            else if (item.Name.Contains("Enter your email address"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Encountered a Problem"), "Skip");
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(item, "Close");
                                }
                                catch (Exception) { }
                            }

                            else if(item.Name.Contains("Encountered a Problem"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Skip");
                                }
                                catch (Exception) { }

                            }

                            //Warning window handler
                            else if (item.Name.Contains("Warning"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Warning", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(item, "Continue");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Warning", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(item, "Start");
                                    Actions.WaitForAnyChildWindow(qbWindow, "Warning", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "QuickBooks File Doctor"), "Continue");
                                }
                                catch (Exception) { }

                            }

                            //QuickBooks File Doctor window handler
                            else if (item.Name.Contains("QuickBooks File Doctor"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Continue");
                                    Actions.WaitForAnyChildWindow(qbWindow, "QuickBooks File Doctor", int.Parse(Sync_Timeout));
                                }
                                catch (Exception) { }
                            }

                            //Home window handler
                            else if (item.Name.Contains("Home"))
                            {
                                try { Actions.ClickElementByName(item, "Close");
                                Thread.Sleep(int.Parse(Execution_Speed));}
                                catch (Exception) { }
                            }

                            //Enter memorized transaction window handler
                            else if (item.Name.Contains("Enter Memorized Transactions"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "Enter All Later");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch { }

                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch { }
                            }

                            //Enter memorized transaction window handler
                            else if (item.Name.Contains("Enter Memorized Transactions"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch { }
                            }

                            //Insights works on accural basis window handler
                            else if (item.Name.Contains("Insights works on the accrual basis only"))
                            {
                                try
                                {
                                    Actions.ClickElementByName(item, "OK");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch { }
                            }

                            //Alert window handler
                            else
                            {
                                try
                                {
                                    Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "OK");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch (Exception) { }

                                try
                                {
                                    Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "No");
                                    Thread.Sleep(int.Parse(Execution_Speed));
                                }
                                catch (Exception) { }
                            }
                        }
                    }
                    else
                    {
                        //ResetQBWindows(qbApp, qbWindow);
                        break;
                    }
                    Thread.Sleep(int.Parse(Execution_Speed));
                }
                while (modalWin.Count != 0);
                Thread.Sleep(int.Parse(Execution_Speed));
            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 4
0
        //**************************************************************************************************************************************************************

        public static void ResetQBWindows(TestStack.White.Application qbApp, Window qbWin, bool openFileOnNoCompany)
        {

            Logger.logMessage("                 ResetQBWindows " + " - Begin");

            List<Window> modalWin = null;
            int iteration = 0;
            bool menuEnabled = false;

            try
            {
                do
                {
                    try
                    {
                        Logger.logMessage("---------------Try-Catch Block------------------------");
                        Actions.SelectMenu(qbApp, qbWin, "Window", "Close All");
                    }
                    catch (Exception) { }

                    do
                    {
                        //Alert window handler
                        if (Actions.CheckDesktopWindowExists("Alert"))
                            Actions.CheckForAlertAndClose("Alert");

                        //Crash handler
                        if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
                        {
                            Actions.QBCrashHandler();
                            break;
                        }

                        if (iteration <= 10)
                        {
                            iteration = iteration + 1;
                            modalWin = qbWin.ModalWindows();

                            foreach (Window item in modalWin)
                            {
                                //Alert window handler
                                if (Actions.CheckDesktopWindowExists("Alert"))
                                    Actions.CheckForAlertAndClose("Alert");

                                //Crash handler
                                if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
                                {
                                    Actions.QBCrashHandler();
                                    break;
                                }

                                 //Enter memorize report window handler
                                else if (item.Name.Contains("Memorize Report"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "No");
                                        Thread.Sleep(int.Parse(Execution_Speed));
                                    }
                                    catch { }
                                }

                                //Handle Save commented report popup
                                else if (item.Name.Contains("Save Your Commented Report?"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "No");
                                        Thread.Sleep(int.Parse(Execution_Speed));
                                    }
                                    catch { }
                                }

                                try
                                {
                                    Logger.logMessage("---------------Try-Catch Block------------------------");
                                    if (Actions.CheckMenuEnabled(qbApp, qbWin, "File"))
                                    {
                                        menuEnabled = true;
                                        break;
                                    }
                                }
                                catch (Exception)
                                { }

                                //Register QB window handler
                                if (item.Name.Contains("Register QuickBooks"))
                                {
                                    try
                                    {

                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Remind Me Later");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Admin permission needed window handler
                                if (item.Name.Contains("Administrator Permissions Needed"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Continue");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //No company window handler
                                else if (item.Name.Contains("No") && openFileOnNoCompany.Equals(true))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        QuickBooks.OpenOrUpgradeCompanyFile(PathBuilder.GetPath("DefaultCompanyFile.qbw"), qbApp, qbWin, false, false);
                                    }
                                    catch { }
                                }

                                //Update quickbooks window handler
                                else if (item.Name.Contains("Update QuickBooks"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Close");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Payroll update window handler
                                else if (item.Name.Equals("Payroll Update"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Cancel");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }

                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }

                                }

                                //Intuit payroll services window hadler
                                else if (item.Name.Contains("Intuit Payroll Services"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Employer services window handler
                                else if (item.Name.Contains("Employer Services"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Cancel");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Insights works on the accrual basis window handler
                                else if (item.Name.Equals("Insights works on the accrual basis only"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Insights works on the accrual basis window handler
                                else if (item.Name.Contains("Insights"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Enter memorized transactions window handler
                                else if (item.Name.Contains("Enter Memorized Transactions"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(Actions.GetChildWindow(qbWin, "Enter Memorized Transactions"), "Enter All Later");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }

                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(Actions.GetChildWindow(qbWin, "Enter Memorized Transactions"), "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }

                                //Recording transaction window handler
                                else if (item.Name.Contains("Recording Transaction"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "No");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }


                                //Login window handler
                                else if (item.Name.Equals("QuickBooks Login"))
                                {
                                    Actions.SetFocusOnWindow(item);
                                    Actions.SendBCKSPACEToWindow(item);
                                    Actions.SetTextByAutomationID(item, "15922", UserName);
                                    Actions.SendTABToWindow(item);
                                    Actions.SendKeysToWindow(item, Password);
                                    Actions.ClickElementByAutomationID(item, "51");
                                    Actions.WaitForAnyChildWindow(qbWin, "QuickBooks Login", int.Parse(Sync_Timeout));
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }

                                //Error window handler
                                else if (item.Name.Contains("Error"))
                                {
                                    Actions.ClickElementByName(item, "Don't Send");
                                    Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                }


                                //QB Setup window handler
                                else if (item.Name.Contains("Setup"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Close");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch (Exception)
                                    { }

                                    try
                                    {

                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Yes");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch (Exception)
                                    { }

                                }

                                //Warning window handler
                                else if (item.Name.Contains("Warning"))
                                {
                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch (Exception)
                                    { }

                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Cancel");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch (Exception)
                                    { }

                                }

                                else
                                {
                                    item.Focus();

                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(Actions.GetChildWindow(qbWin, "Recording Transaction"), "No");
                                    }
                                    catch { }

                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "Close");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }

                                    try
                                    {

                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "No");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }


                                    try
                                    {
                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        item.Close();
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }

                                    try
                                    {

                                        Logger.logMessage("---------------Try-Catch Block------------------------");
                                        Actions.ClickElementByName(item, "OK");
                                        Thread.Sleep(int.Parse(ResetWindow_Timeout));
                                    }
                                    catch { }
                                }
                            }
                            Thread.Sleep(int.Parse(Execution_Speed));
                        }
                        else
                        {
                            break;
                        }
                    }
                    while (modalWin.Count != 0 && menuEnabled.Equals(false));
                    Thread.Sleep(int.Parse(Execution_Speed));
                }
                while (!Actions.CheckMenuEnabled(qbApp, qbWin, "File"));

                Logger.logMessage("                 ResetQBWindows " + " - End");
                Logger.logMessage("------------------------------------------------------------------------------");
            }

            catch (Exception e)
            {
                Logger.logMessage("ResetQBWindows " + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 5
0
        //**************************************************************************************************************************************************************
        public static Window GetWindow(Window win, String winName)
        {
            Window window = null;

            try
            {
                List<Window> modalWins = win.ModalWindows();
                foreach (Window item in modalWins)
                {
                    if(item.Name.Equals(winName) || item.Name.Contains(winName))
                    {
                        window = item;
                        window.Focus();
                        window.DoubleClick();
                        Thread.Sleep(int.Parse(Execution_Speed));
                    }
                }

                return window;

            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 6
0
        //**************************************************************************************************************************************************************
        public static Window GetChildWindow(Window mainWindow, string childWindowName)
        {
            Window childWindow = null;

            try
            {
                List<Window> allChildWindows = mainWindow.ModalWindows();

                foreach (Window w in allChildWindows)
                {
                    if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
                    {
                        childWindow = w;
                        break;
                    }
                }

                return childWindow;
            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 7
0
        //**************************************************************************************************************************************************************
        public static bool WaitForChildWindow(Window mainWindow, string childWindowName, long timeOut)
        {
            bool windowFound = false;
            long elapsedTime = 0;
            var stopwatch = Stopwatch.StartNew();

            try
            {
                do
                {
                    if (windowFound)
                        break;

                    elapsedTime = stopwatch.ElapsedMilliseconds;

                    List<Window> allChildWindows = mainWindow.ModalWindows();

                    foreach (Window w in allChildWindows)
                    {
                        try
                        {
                            Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "OK");
                            Thread.Sleep(int.Parse(Execution_Speed));
                        }
                        catch (Exception) { }

                        try
                        {
                            Actions.ClickElementByName(Actions.GetAlertWindow("Alert"), "No");
                            Thread.Sleep(int.Parse(Execution_Speed));
                        }
                        catch (Exception) { }

                        if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
                        {
                            windowFound = true;
                            break;
                        }
                    }
                }
                while (elapsedTime<=timeOut);

                return windowFound;
            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 8
0
        //**************************************************************************************************************************************************************
        public static void CloseAllChildWindows(Window window)
        {
            try
            {
                List<Window> modalWindows = window.ModalWindows();
                foreach (Window win in modalWindows)
                {
                    win.Focus();

                    try { FrameworkLibraries.ActionLibs.QBDT.WhiteAPI.Actions.ClickElementByName(win, "Close"); }
                    catch { }

                    try { win.Close(); }
                    catch { }
                }
            }
            catch (Exception e)
            {
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 9
0
        //**************************************************************************************************************************************************************

        public static void CloseAllChildWindows(Window window)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            try
            {
                List<Window> modalWindows = window.ModalWindows();
                foreach (Window win in modalWindows)
                {
                    win.Focus();

                    try { FrameworkLibraries.ActionLibs.WhiteAPI.Actions.ClickElementByName(win, "Close"); }
                    catch { }

                    try { win.Close(); }
                    catch { }
                }
                Logger.logMessage("CloseAllChildWindows " + window + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");

            }
            catch (Exception e)
            {
                Logger.logMessage("CloseAllChildWindows " + window + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }
Ejemplo n.º 10
0
        //**************************************************************************************************************************************************************


        public static bool CheckWindowExists(Window mainWindow, string childWindowName)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            bool window = false;

            try
            {
                List<Window> allChildWindows = mainWindow.ModalWindows();

                foreach (Window w in allChildWindows)
                {
                    if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
                    {
                        window = true;
                        Thread.Sleep(int.Parse(Execution_Speed));
                        break;
                    }
                }
                Logger.logMessage("CheckWindowExists " + mainWindow + "->" + childWindowName + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
                return window;
            }
            catch (Exception e)
            {
                Logger.logMessage("CheckWindowExists " + mainWindow + "->" + childWindowName + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");

                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
Ejemplo n.º 11
0
        //**************************************************************************************************************************************************************

        public static bool WaitForAnyChildWindow(Window mainWindow, string currentWindowName, long timeOut)
        {
            var qbApp = Actions.GetApp("QuickBooks", "qbw32");
            var qbWindow = Actions.GetAppWindow(qbApp, "QuickBooks");

            Logger.logMessage("Function call @ :" + DateTime.Now);
            Logger.logMessage("                 WaitForAnyChildWindow " + mainWindow + "->" + currentWindowName + " - Begin Sync");

            bool windowFound = false;
            long elapsedTime = 0;
            var stopwatch = Stopwatch.StartNew();

            try
            {
                do
                {
                    //Alert window handler
                    if (Actions.CheckDesktopWindowExists("Alert"))
                        Actions.CheckForAlertAndClose("Alert");

                    try { Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Warning"), "OK"); }
                    catch (Exception) { }

                    //Crash handler
                    if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
                    {
                        Actions.QBCrashHandler();
                        break;
                    }

                    if (windowFound)
                        break;

                    elapsedTime = stopwatch.ElapsedMilliseconds;

                    List<Window> allChildWindows = mainWindow.ModalWindows();

                    foreach (Window w in allChildWindows)
                    {

                        if (Actions.CheckDesktopWindowExists("Alert"))
                            Actions.CheckForAlertAndClose("Alert");

                        try { Actions.ClickElementByName(Actions.GetChildWindow(qbWindow, "Warning"), "OK"); }
                        catch (Exception) { }

                        //Crash handler
                        if (Actions.CheckDesktopWindowExists("QuickBooks - Unrecoverable Error"))
                        {
                            Actions.QBCrashHandler();
                            break;
                        }

                        if (!w.Name.Equals(currentWindowName) || !w.Name.Contains(currentWindowName))
                        {
                            windowFound = true;
                            w.WaitWhileBusy();
                            break;
                        }
                    }
                }
                while (elapsedTime <= timeOut);
                Logger.logMessage("                 WaitForAnyChildWindow " + mainWindow + "->" + currentWindowName + " - End Sync");
                Logger.logMessage("------------------------------------------------------------------------------");

                return windowFound;
            }
            catch (Exception e)
            {
                Logger.logMessage("WaitForAnyChildWindow " + mainWindow + "->" + currentWindowName + " - Terminated");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");

                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
Ejemplo n.º 12
0
        //**************************************************************************************************************************************************************
        public static Window GetChildWindow(Window mainWindow, string childWindowName)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            Window childWindow = null;

            try
            {
                List<Window> allChildWindows = mainWindow.ModalWindows();

                foreach (Window w in allChildWindows)
                {
                    if (w.Name.Equals(childWindowName) || w.Name.Contains(childWindowName))
                    {
                        childWindow = w;
                        break;
                    }
                }
                Logger.logMessage("GetChildWindow " + mainWindow + "->" + childWindowName + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
                return childWindow;
            }
            catch (Exception e)
            {
                Logger.logMessage("GetChildWindow " + mainWindow + "->" + childWindowName + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }

        }
Ejemplo n.º 13
0
        //**************************************************************************************************************************************************************

        public static Window GetWindow(Window win, String winName)
        {
            Logger.logMessage("Function call @ :" + DateTime.Now);
            Window window = null;

            try
            {
                List<Window> modalWins = win.ModalWindows();
                foreach (Window item in modalWins)
                {
                    Logger.logMessage(item.Name);

                    if (item.Name.Equals(winName) || item.Name.Contains(winName))
                    {
                        window = item;
                        window.Focus();
                        window.DoubleClick();
                        Thread.Sleep(int.Parse(Execution_Speed));
                    }
                }
                Logger.logMessage("GetWindow " + winName + " - Successful");
                Logger.logMessage("------------------------------------------------------------------------------");
                return window;

            }
            catch (Exception e)
            {
                Logger.logMessage("GetWindow " + winName + " - Failed");
                Logger.logMessage(e.Message);
                Logger.logMessage("------------------------------------------------------------------------------");
                String sMessage = e.Message;
                LastException.SetLastError(sMessage);
                throw new Exception(sMessage);
            }
        }