Esempio n. 1
0
        internal void ClickGoogleLinkAndFillInformation()
        {
            InitiateWaitVariable();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath("//span[contains(text(),'Google')]"))).Click();

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//input[@type='email']"))).SendKeys("*****@*****.**");

            Driver.FindElement(By.XPath("//*[@class='VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ VfPpkd-LgbsSe-OWXEXe-dgl2Hf nCP5yc AjY5Oe DuMIQc qIypjc TrZEUc lw1w4b']")).Click();

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@type='password']"))).SendKeys("lordNikon");

            Driver.FindElement(By.XPath("//*[@class='VfPpkd-LgbsSe VfPpkd-LgbsSe-OWXEXe-k8QpJ VfPpkd-LgbsSe-OWXEXe-dgl2Hf nCP5yc AjY5Oe DuMIQc qIypjc TrZEUc lw1w4b']")).Click();

            bool isAcctCreated;

            try
            {
                var acctCreated = wait.Until(ExpectedConditions.ElementExists(By.XPath("//span[contains(text(),'Hi Yavor')]"))).Enabled;
                isAcctCreated = Convert.ToBoolean(acctCreated);
            }
            catch (WebDriverTimeoutException exc)
            {
                Console.WriteLine(exc.Message);
                isAcctCreated = false;
            }

            if (isAcctCreated)
            {
                var myAcct = Driver.FindElement(By.XPath("//span[@type='accountFilled']"));
                myAcct.Click();

                var acctName = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//span[contains(text(),'Hi Yavor')]"))).Text;

                Console.WriteLine("You have already registered account with this name: " + acctName);
            }
            else
            {
                wait.Until(ExpectedConditions.ElementIsVisible(By.Id("BirthDay"))).Click();

                Driver.FindElement(By.XPath("//option[@value='27']")).Click();
                Driver.FindElement(By.Id("BirthMonth")).Click();
                Driver.FindElement(By.XPath("//option[contains(text(),'January')]")).Click();
                Driver.FindElement(By.Id("BirthYear")).Click();
                Driver.FindElement(By.XPath("//option[@value='1982']")).Click();
                Driver.FindElement(By.XPath("//label[contains(text(),'Menswear')]")).Click();
                Driver.FindElement(By.Id("promosLabel")).Click();
                Driver.FindElement(By.Id("newnessLabel")).Click();
                Driver.FindElement(By.Id("register")).Click();
            }
        }
Esempio n. 2
0
 public WebElement WaitUntilElementExists(By lookupBy, int timeout = 10)
 {
     try
     {
         var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));
         return(wait.Until(ExpectedConditions.ElementExists(lookupBy)));
     }
     catch (NoSuchElementException ex)
     {
         try
         {
             TakeScreenShot();
             // Assert.Fail(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
             throw new Exception(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
         }
         catch (Exception ex1)
         {
             throw new Exception("Failed to take screenshot: " + ex1.ToString());
         }
     }
 }
Esempio n. 3
0
        internal IWebElement waitForElementIsPresent(By lookupBy, int maxWaitTime = 60)
        {
            IWebElement element = null;

            try
            {
                element = new WebDriverWait(driver, TimeSpan.FromSeconds(maxWaitTime)).Until(ExpectedConditions.ElementExists(lookupBy));
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }
            if (element != null)
            {
                try
                {
                    string             script     = String.Format(@"arguments[0].style.cssText = ""border-width: 4px; border-style: solid; border-color: {0}"";", "orange");
                    JavascriptExecutor jsExecutor = (JavascriptExecutor)driver;
                    jsExecutor.ExecuteScript(script, new object[] { element });
                    jsExecutor.ExecuteScript(String.Format(@"$(arguments[0].scrollIntoView(true));"), new object[] { element });
                }
                catch { }
            }
            return(element);
        }