コード例 #1
0
        public bool sSelectorSelect(IWebElement element, string text)
        {
            WaitUtilities.WaitForPostBack(_webDriver);


            if (!element.Displayed)
            {
                Debug.WriteLine("ERROR: Selector Is not available to fill");
                Debug.WriteLine("Selector ID: " + element.GetAttribute("id"));
                return(false);
            }

            if (element.GetAttribute("value") == text || element.Text == text) // TODO: WATCH THIS, GW is wonky and it may not always be value
            {
                return(true);
            }

            sClick(element);

            if (_webDriver.FindElementByXPath("//li[contains(text(), '" + text + "')]").Displayed)
            {
                sClick(_webDriver.FindElementByXPath("//li[contains(text(), '" + text + "')]"));
                Thread.Sleep(50);
            }

            return(true);
        }
コード例 #2
0
        public void LoginToAliExpress(Login login)
        {
            bool isAdClosed = false;

            try
            {
                WaitUtilities.WaitForElementNTimes(driver, adsCloseButtonLocator, TimeSpan.FromSeconds(5), 3);
                Click(AdsCloseButton);
                WaitUtilities.WaitForElementNTimes(driver, newUserAdNotificationLocator, TimeSpan.FromSeconds(5), 3);
                isAdClosed = true;
            }
            catch (NoSuchElementException e)
            {
                Console.WriteLine("DEBUG: Could not locate ad: " + e.Message);
            }

            WaitUtilities.WaitForElementNTimes(driver, goToGlobalSiteLinkLocator, TimeSpan.FromSeconds(5), 3);
            wait.Until(ExpectedConditions.ElementToBeClickable(goToGlobalSiteLinkLocator));
            Click(GoToGlobalSiteLink);

            if (!isAdClosed)
            {
                try
                {
                    WaitUtilities.WaitForElementNTimes(driver, adsCloseButtonLocator, TimeSpan.FromSeconds(5), 3);
                    Click(AdsCloseButton);
                    WaitUtilities.WaitForElementNTimes(driver, newUserAdNotificationLocator, TimeSpan.FromSeconds(5), 3);
                    isAdClosed = true;
                }
                catch (NoSuchElementException e)
                {
                    Console.WriteLine("DEBUG: Could not locate ad: " + e.Message);
                }
            }

            WaitUtilities.WaitForElementNTimes(driver, signInButtonLocator, TimeSpan.FromSeconds(5), 3);
            Click(SignInButton);


            WaitUtilities.WaitForElementNTimes(driver, aliExpressLoginFormLocator, TimeSpan.FromSeconds(5), 3);
            driver.SwitchTo().Frame(AliExpressLoginForm);


            WaitUtilities.WaitForElementNTimes(driver, loginFieldLocator, TimeSpan.FromSeconds(5), 3);
            SendText(LoginField, login.login);


            WaitUtilities.WaitForElementNTimes(driver, passwordFieldLocator, TimeSpan.FromSeconds(5), 3);
            SendText(PasswordField, login.password);


            WaitUtilities.WaitForElementNTimes(driver, loginSubmitButtonLocator, TimeSpan.FromSeconds(5), 3);
            Click(LoginSubmitButton);
        }
コード例 #3
0
        public bool clickSearchSubmission()
        {
            OpenQA.Selenium.Interactions.Actions builder = new OpenQA.Selenium.Interactions.Actions(_webDriver);

            builder.MoveToElement(btnSearchTab)
            .MoveByOffset(30, 0)
            .Click()
            .Build()
            .Perform();
            WaitUtilities.WaitForPostBack(_webDriver);
            return(sClick(btnSubmissionSearch));
        }
コード例 #4
0
        public void TriggerPostBack(IWebElement element)
        {
            WaitUtilities.WaitForPostBack(_webDriver);


            if (_webDriver.FindElementByXPath("//img[contains(@class,'product-logo')]").Displayed)
            {
                sClick(_webDriver.FindElementByXPath("//img[contains(@class,'product-logo')]"));
            }
            else
            {
                element.SendKeys(Keys.Tab);
                WaitUtilities.WaitForPostBack(_webDriver);
            }
        }
コード例 #5
0
 public bool Login(string User, string Password)
 {
     if (IsAt() && (txtUserName.Displayed && txtPassword.Displayed && btnUserName.Displayed))
     {
         WaitUtilities.WaitForPostBack(_webDriver);
         sSendKeys(txtUserName, User);
         sSendKeys(txtPassword, Password);
         sClick(btnUserName);
         WaitUtilities.WaitForPostBack(_webDriver);
         return(true);
     }
     else
     {
         Debug.WriteLine("ERROR: Unable to login!");
         return(false);
     }
 }
コード例 #6
0
        //[OneTimeSetUp]
        public void Initialize(string center)
        {
            Browser   = new BrowserBase();
            Pages     = new PagesBase(Browser);
            WorkFlows = new WorkFlowsBase(Pages);
            ChromeOptions options = new ChromeOptions();

            options.AddArgument("start-maximized");
            //options.AddArgument("--log-level=3");
            //options.AddArgument("--silent");
            //options.AddArgument("--disable-logging");
            //options.AddArgument("sync-short-nudge-delay-for-test");
            options.Proxy = null;
            ChromeDriver driver = new ChromeDriver(ResourcesBase.ChromeDriverPath, options);

            Browser.Initialize(driver, center);
            _webDriver = driver;
            Thread.Sleep(RandomNumberGeneratorUtilities.GetRandomNumber(10) * 100 + 3000);
            WaitUtilities.WaitForPostBack(_webDriver);
        }
コード例 #7
0
        // Use this selector when there are multiple selectors with the same set of values to choose from
        public bool sAltSelectorSelect(IWebElement element, string text)
        {
            WaitUtilities.WaitForPostBack(_webDriver);


            if (!element.Displayed)
            {
                Debug.WriteLine("ERROR: Selector Is not available to fill");
                Debug.WriteLine("Selector ID: " + element.GetAttribute("id"));
                return(false);
            }

            if (element.GetAttribute("value") == text || element.Text == text) // TODO: WATCH THIS, GW is wonky and it may not always be value
            {
                return(true);
            }

            WaitUtilities.WaitForPostBack(_webDriver);
            sClick(element);
            WaitUtilities.WaitForPostBack(_webDriver);
            sSendKeys(element, text);
            return(true);
        }
コード例 #8
0
 public MyOrdersPage NavigateToMyOrdersPage()
 {
     WaitUtilities.WaitForElementNTimes(driver, myOrdersLinkLocator, TimeSpan.FromSeconds(5), 3);
     Click(MyOrdersLink);
     return(new MyOrdersPage(driver, wait));
 }
コード例 #9
0
        public bool sSendKeys(IWebElement element, string text)
        {
            //WaitUtilities.WaitForPostBack(_webDriver);


            bool done       = false;
            int  numRetries = 0;

            while (!done && numRetries < 50)
            {
                try
                {
                    if (!element.Displayed)
                    {
                        element.Click();
                        Thread.Sleep(100);
                        if (!element.Displayed)
                        {
                            element.Click();
                            Thread.Sleep(100);
                            if (!element.Displayed)
                            {
                                WaitUtilities.WaitForPostBack(_webDriver);
                                element.Click();
                                Thread.Sleep(300);
                                if (!element.Displayed)
                                {
                                    Debug.WriteLine("ERROR: TextBox Is not available to fill");
                                    Debug.WriteLine("TextBox ID: " + element.GetAttribute("id"));
                                    return(false);
                                }
                            }
                        }
                    }
                    done = true;
                }
                catch (WebDriverException)
                {
                    WaitUtilities.WaitForPostBack(_webDriver);
                    numRetries++;
                }
            }

            // Optimization to not enter if it's already set.. saves postback time!
            if (element.GetAttribute("value") == text || element.Text == text) // TODO: WATCH THIS, GW is wonky and it may not always be value
            {
                return(true);
            }
            element.Clear();

            try
            {
                element.SendKeys(text);
            }
            catch (StaleElementReferenceException)
            {
                Thread.Sleep(500);
                element.SendKeys(text);
            }

            TriggerPostBack(element);
            return(true);
        }
コード例 #10
0
        public bool sClick(IWebElement element)
        {
            //WaitUtilities.WaitForPostBack(_webDriver);


            if (!element.Displayed && !element.GetAttribute("class").Contains("disabled"))
            {
                Debug.WriteLine("ERROR: Button Is not available to click");
                Debug.WriteLine("Button ID: " + element.GetAttribute("id"));
                return(false);
            }

            try
            {
                element.Click();
            }
            catch (WebDriverException)
            {
                try
                {
                    Thread.Sleep(25);
                    element.Click();
                }
                catch (WebDriverException)
                {
                    try
                    {
                        Thread.Sleep(25);
                        element.Click();
                    }
                    catch (WebDriverException)
                    {
                        try
                        {
                            WaitUtilities.WaitForPostBack(_webDriver);
                            element.Click();
                        }
                        catch (WebDriverException)
                        {
                            try
                            {
                                WaitUtilities.WaitForPostBack(_webDriver);
                                element.Click();
                            }
                            catch (WebDriverException)
                            {
                                try
                                {
                                    WaitUtilities.WaitForPostBack(_webDriver);
                                    element.Click();
                                }
                                catch (WebDriverException)
                                {
                                    try
                                    {
                                        WaitUtilities.WaitForPostBack(_webDriver);
                                        element.Click();
                                    }
                                    catch (WebDriverException)
                                    {
                                        WaitUtilities.WaitForPostBack(_webDriver);
                                        element.Click();
                                    }
                                }
                            }
                        }
                    }
                }
            }

            WaitUtilities.WaitForPostBack(_webDriver);
            return(true);
        }