Exemple #1
0
        public void clickOnYesToNewCustomerDiscountsPopUp()
        {
            //The Yes element cannot be accessed like normal elements because it is in a separate popup window
            //So you need to switch to that windon before you attempt to access it.
            //It won't wait for the element until the switch is complete, so I have used a loop to allow it to try again
            //Once the Yes element has been clicked on, you then need to wait for it to disappear before the focus is back on
            //the main window.

            string yesLocatorString = "//*[@id='toast']/ul/li/span[2]";

            switchWindowLast();
            for (int i = 0; i < 10; i++)
            {
                try
                {
                    IWebElement yes = MyDriverManager.waitForAndReturnElementByXpath(yesLocatorString);
                    DataEntryHelper.ClickOn(yes);

                    MyDriverManager.waitForElementToDisappearByXpath(yesLocatorString);
                    break;
                }
                catch (Exception e)
                {
                    //This should loop back to try again
                    MyDriverManager.pause(1000);
                }
            }
        }
Exemple #2
0
        public void selectCustomerEmail(string email)
        {
            string emailLocatorString = "//*[contains(text(),'" + email + "')]";

            for (int i = 0; i < 10; i++)
            {
                try
                {
                    MyDriverManager.pause(1000);
                    IWebElement theCustomerEmail =
                        MyDriverManager.driver.FindElement(By.XPath(emailLocatorString));
                    DataEntryHelper.ClickOn(theCustomerEmail);
                    break;
                }
                catch (Exception e)
                {
                    //This should allow the for loop to continue so it tries again
                }
            }
        }