Example #1
0
        public bool waitForVisibilityOfElement(By lookupBy, double timeout)
        {
            bool          flag = false;
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));

            try
            {
                WebElement ele = wait.Until(ExpectedConditions.ElementIsVisible(lookupBy));
                flag = true;
                ExtentReport.ReportPass("The element is visible before <b>" + timeout + "</b> seconds");
            }
            catch (Exception ex)
            {
                try
                {
                    //TakeScreenShot();
                    ExtentReport.ReportFail("The element is not visible :<b>" + ex.Message + "</b>");
                    //Assert.Fail(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
                    flag = false;
                }
                catch (Exception ex1)
                {
                    //Assert.Fail("Failed to take screenshot: " + ex1.ToString());
                }
            }

            return(flag);
        }
Example #2
0
        public bool waitForVisibilityOfElementUntillTimeout(By lookupBy, double timeout)
        {
            bool          bln  = false;
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(timeout));

            try
            {
                WebElement ele = wait.Until(ExpectedConditions.ElementIsVisible(lookupBy));//sunil
                bln = true;
            }
            catch (Exception ex)
            {
                try
                {
                    TakeScreenShot();
                    Assert.Fail(lookupBy + " is not visible for " + timeout + " seconds." + " with message :" + ex.Message);
                    throw new Exception(ex.Message);
                }
                catch (Exception ex1)
                {
                    Assert.Fail("Failed to take screenshot: " + ex1.ToString());
                }
            }

            return(bln);
        }
        internal void ClickMyAccountLink()
        {
            Driver.FindElement(By.XPath("//*[@type='accountUnfilled']")).Click();

            InitiateWaitVariable();
            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@data-testid='myaccount-link']"))).Click();
        }
        internal EasyReturnsPage ClickEasyReturnsLink()
        {
            InitiateWaitVariable();
            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//p[contains(text(),'Easy')]"))).Click();

            return(new EasyReturnsPage(Driver));
        }
        internal void ClickJoinLink()
        {
            Driver.FindElement(By.XPath("//*[@type='accountUnfilled']")).Click();

            InitiateWaitVariable();
            //var wait = new WebDriverWait(Driver,TimeSpan.FromSeconds(5));
            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@data-testid='signup-link']"))).Click();
        }
        internal void ClickContactPreferencesLink()
        {
            InitiateWaitVariable();

            var acctMsg = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@data-testid='myAccountIcon']")));

            acctMsg.Click();

            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@data-testid='contactpreferences-link']"))).Click();
        }
        internal ReturnsInformationPage ClickReturnsInformationLink()
        {
            InitiateWaitVariable();
            var acctMsg = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@data-testid='myAccountIcon']")));

            acctMsg.Click();
            var returnsLink = wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//*[@data-testid='returnsinformation-link']")));

            returnsLink.Click();

            return(new ReturnsInformationPage(Driver));
        }
 public bool FIndElementIsPresent(By by)
 {
     try
     {
         var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
         wait.Until(ExpectedConditions.ElementIsVisible(by));
         return(true);
     }
     catch (NoSuchElementException)
     {
         return(false);
     }
 }
        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();
            }
        }
Example #10
0
        internal ContactPreferencesPage ClickGoogleToLogIn()
        {
            InitiateWaitVariable();
            wait.Until(ExpectedConditions.ElementIsVisible(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();

            return(new ContactPreferencesPage(Driver));
        }
Example #11
0
        public void CuandoSeArriesgaLaPalabraAutomaticamente()
        {
            var waitMostrarPalabraAAdivinar = new WebDriverWait(chromeDriver, System.TimeSpan.FromSeconds(10));

            waitMostrarPalabraAAdivinar.Until(ExpectedConditions.ElementIsVisible(By.Id("ButtonFlagPalabraAAdivinar")));
            var botonMostrarPalabraAAdivinar = chromeDriver.FindElementById("ButtonFlagPalabraAAdivinar");

            botonMostrarPalabraAAdivinar.Click();

            var waitPalabraAAdivinar = new WebDriverWait(chromeDriver, System.TimeSpan.FromSeconds(10));

            waitPalabraAAdivinar.Until(ExpectedConditions.ElementIsVisible(By.Id("PalabraAAdivinar")));
            var textoPalabraAAdivinar = chromeDriver.FindElementById("PalabraAAdivinar");

            CuandoSeArriesgaLaPalabra(textoPalabraAAdivinar.Text);
            Thread.Sleep(TimeSpan.FromSeconds(2));
        }
Example #12
0
        public void LogintoMyPage(LoginSelectorsModel loginCssSelectors, string username, string password, string partername)
        {
            Console.WriteLine(partername);
            _logger.Debug("trying to login ");
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));

            if (partername != "AdjaraBet")
            {
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(loginCssSelectors.LoginFormBtn)));
                driver.FindElement(By.CssSelector(loginCssSelectors.LoginFormBtn)).Click();
            }
            driver.FindElement(By.CssSelector(loginCssSelectors.UserNameInput)).SendKeys(username);
            driver.FindElement(By.CssSelector(loginCssSelectors.PasswordInput)).SendKeys(password);
            driver.FindElement(By.CssSelector(loginCssSelectors.LoginBtn)).Click();

            Thread.Sleep(1000);
        }
        public void ExecuteLogin()
        {
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            Assert.Multiple(() =>
            {
                Assert.IsTrue(driver.Url.Equals(screenUrl), "URL is incorrect");
                Assert.AreEqual(driver.Title, "The world’s leading software development platform · GitHub", "Page title is incorrect");
                Assert.IsTrue(driver.FindElement(By.XPath("//a[@class='HeaderMenu-link no-underline mr-3']")).Displayed, "Button 'Sign In' is absent");
            });
            Log.Information("First block of Asserts is passed");

            LoginPage loginPage = new LoginPage();

            PageFactory.InitElements(driver, loginPage);


            loginPage.firstButton.Click();
            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//input[@name='commit']")));

            Assert.Multiple(() =>
            {
                Assert.AreEqual(driver.Title, "Sign in to GitHub · GitHub", "Page title is incorrect");
                Assert.IsTrue(driver.FindElement(By.XPath("//a[@class='label-link']")).Text.Equals("Forgot password?"), "Button 'FP' is absent");
                Assert.IsTrue(driver.FindElement(By.XPath(" //p[@class='create-account-callout mt-3']")).Displayed, "Block 'CA' is absent");
            });

            Log.Information("Second block of Asserts is passed");

            if (
                driver.FindElement(By.XPath("//input[@name='commit']")).Displayed &&
                driver.FindElement(By.XPath("//input[@id='login_field']")).Displayed &&
                driver.FindElement(By.XPath("//input[@id='password']")).Displayed
                )
            {
                loginPage.typeEmail.SendKeys(emailLogin);
                loginPage.typePassword.SendKeys(passwordLogin);
                loginPage.signInButton.Click();
                Log.Information("Login process is executed successfully! Time is {Now}", DateTime.Now);
            }
            else
            {
                Log.Error("Expected elements are absent!Time is {Now}", DateTime.Now);
            }
        }
Example #14
0
 internal void ClickWomenLink()
 {
     InitiateWaitVariable();
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("women-floor"))).Click();
 }
Example #15
0
        public void PrematchBet(CheckBetModel selectors, string Name, GetNumberOfGamesCssSelectorsModel se)
        {
            WebDriverWait wait  = new WebDriverWait(driver, TimeSpan.FromMilliseconds(3000));
            WebDriverWait wait1 = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            WebDriverWait wait2 = new WebDriverWait(driver, TimeSpan.FromSeconds(2));
            WebDriverWait wait3 = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait1.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.FrameToBeAvailableAndSwitchToIt(se.FrameName));
            Stopwatch s = new Stopwatch();

            s.Start();
            while (!CheckPresence.Check(driver, "span[class='inner']") && s.Elapsed < TimeSpan.FromSeconds(10))
            {
            }
            s.Stop();
            wait3.Until(ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector("div[class='loader-holder']")));


            try
            {
                driver.FindElements(By.ClassName("inner"))[0].Click();

                try
                {
                    wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div[class='loading-content active']")));
                    wait2.Until(ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector("div[class='loading-content active']")));
                    Console.WriteLine("BetCheck time");
                    _logger.Info("BetCheck time");
                }

                catch
                {
                    Console.WriteLine("NO BetCheck time");
                    _logger.Info("NO BetCheck time");
                }
                IWebElement SingleBetAmountInputElement = wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(selectors.SingleBetAmountInputElement)));
                SingleBetAmountInputElement.SendKeys(selectors.SingleBetAmount);
                try
                {
                    driver.FindElement(By.CssSelector("a[class='bet-btn accept-changes']")).Click();
                    Console.WriteLine("Odds changes were accepted");
                    _logger.Info("Odds changes were accepted");
                }

                catch
                {
                    Console.WriteLine("no Odds change ");
                    _logger.Info("no Odds change");
                }
                wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector(selectors.BetBtn)));
                driver.FindElement(By.CssSelector(selectors.BetBtn)).Click();
                try { driver.FindElement(By.CssSelector("a[class='bet-btn accept-changes']")).Click(); driver.FindElement(By.CssSelector(selectors.BetBtn)).Click(); } catch { }
                wait1.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("i[class='icon efu-checkbox-checked-circle']")));
                Console.ForegroundColor = ConsoleColor.Green;
                Console.WriteLine("Single Bet-OK");
                Console.ResetColor();
                _logger.Info("Single Bet-OK");
            }
            catch (Exception ex)
            {
                screen.TakeScreenshot(Name);
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex.Message + "   Single Bet Fail");
                Console.ResetColor();
                _logger.Info(ex.Message + "Single Bet-Fail");
                try { driver.FindElement(By.CssSelector("i[class='efu-checkbox-error-circle']")).Click(); }
                catch { }
            }
            try
            {
                wait1.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.XPath(selectors.WaitAfterBetElement)));
            }
            catch
            {
                Console.WriteLine("Continue after single Failure ");
                _logger.Info("Continue after single Failure ");
            }
            try
            {
                driver.FindElements(By.XPath(selectors.GameBetElement))[3].Click();
                driver.FindElements(By.XPath(selectors.GameBetElement))[6].Click();



                try
                {
                    wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("div[class='loading-content active']")));
                    wait2.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector("div[class='loading-content active']")));
                    Console.WriteLine("Betcheck time ");
                    _logger.Info("Betcheck time ");
                }
                catch
                {
                    Console.WriteLine("No Betcheck time");
                    _logger.Info("NO Betcheck time ");
                }
                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector(selectors.MultipleBetAmountInputElement)));
                driver.FindElement(By.CssSelector(selectors.MultipleBetAmountInputElement)).SendKeys(selectors.MultipleBetAmount);
                try
                {
                    driver.FindElement(By.CssSelector("a[class='bet-btn accept-changes']")).Click();
                    Console.WriteLine("Odds changes were accepted");
                    _logger.Info("Odds changes were accepted");
                }

                catch
                {
                    Console.WriteLine("no Odds change ");
                    _logger.Info("no Odds change");
                }

                wait.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector(selectors.BetBtn)));
                driver.FindElement(By.CssSelector(selectors.BetBtn)).Click();
                try { driver.FindElement(By.CssSelector("a[class='bet-btn accept-changes']")).Click(); driver.FindElement(By.CssSelector(selectors.BetBtn)).Click(); } catch { }
                try
                {
                    wait1.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.ElementIsVisible(By.CssSelector("i[class='icon efu-checkbox-checked-circle']")));
                    Console.ForegroundColor = ConsoleColor.Green;
                    Console.WriteLine("Multiple Bet-OK");
                    Console.ResetColor();
                    _logger.Info("Multiple Bet-OK");
                    wait1.Until(SeleniumExtras.WaitHelpers.ExpectedConditions.InvisibilityOfElementLocated(By.CssSelector("i[class='icon efu-checkbox-checked-circle']")));
                }
                catch (Exception ex)
                {
                    screen.TakeScreenshot(Name + "BetError");
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine(ex.Message + "   Multiple Bet Fail1");
                    Console.ResetColor();
                    _logger.Info(ex.Message + "   Multiple Bet Fail1");
                    while (CheckPresence.Check(driver, "i[class='efu-checkbox-error-circle']"))
                    {
                        driver.FindElement(By.CssSelector("i[class='efu-checkbox-error-circle']")).Click();
                    }
                }
            }
            catch (Exception exs)
            {
                screen.TakeScreenshot(Name + "BetError");
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(exs.Message + "   Multiple Bet Fail");
                Console.ResetColor();
                _logger.Info(exs.Message + "   Multiple Bet Fail");
                while (CheckPresence.Check(driver, "i[class='efu-checkbox-error-circle']"))
                {
                    driver.FindElement(By.CssSelector("i[class='efu-checkbox-error-circle']")).Click();
                }
            }
        }
Example #16
0
        internal WebElement waitForElementVisible(By lookupBy, int maxWaitTime = 60)
        {
            WebElement element = null;

            try
            {
                element = new WebDriverWait(driver, TimeSpan.FromSeconds(maxWaitTime)).Until(ExpectedConditions.ElementIsVisible(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);
        }
Example #17
0
        protected void WaitElementIsVisible(By locator, int seconds)
        {
            var waiter = new WebDriverWait(_driver, TimeSpan.FromSeconds(seconds));

            waiter.Until(ExpectedConditions.ElementIsVisible(locator));
        }