Beispiel #1
0
                    public void Search()
                    {
                        driver.Navigate().GoToUrl("http://google.com/ncr");

                        driver.FindElement(By.Name("q")).SendKeys("Selenide" + Keys.Enter);

                        /*
                         * new WebDriverWait(driver, TimeSpan.FromSeconds(2))
                         *  .Until(
                         *      ExpectedConditions.TextToBePresentInElementLocated(
                         *          By.CssSelector(".srg>.g:nth-of-type(1)"),
                         *          "Selenide: concise UI tests in Java"
                         *      )
                         *  );
                         */
                        new WebDriverWait(driver, TimeSpan.FromSeconds(2))
                        .Until(
                            ExpectedConditions.TextToBePresentInElement(
                                driver.FindElement(By.CssSelector(".srg>.g:nth-of-type(1)")),
                                "Selenide: concise UI tests in Java"
                                )
                            );

                        driver.FindElements(By.CssSelector(".srg>.g"))[0]
                        .FindElement(By.CssSelector("h3>a")).Click();
                        new WebDriverWait(driver, TimeSpan.FromSeconds(2)).Until(
                            ExpectedConditions.UrlToBe("http://selenide.org/"));
                    }
Beispiel #2
0
        public void Setup()
        {
            new DriverManager().SetUpDriver(new ChromeConfig(), VersionResolveStrategy.MatchingBrowser);
            webDriver = new ChromeDriver();
            webDriver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(7);
            webDriver.Manage().Timeouts().PageLoad     = TimeSpan.FromSeconds(60);

            webDriver.Navigate().GoToUrl("https://newbookmodels.com/join");
            WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));

            webDriver.FindElement(By.CssSelector("[name^=first_name]")).SendKeys(validFirstName);
            webDriver.FindElement(By.CssSelector("[name^=last_name]")).SendKeys(validLastName);
            webDriver.FindElement(By.CssSelector("[name^=email]")).SendKeys(validemail);
            webDriver.FindElement(By.CssSelector("[name=password]")).SendKeys(validPassword);
            webDriver.FindElement(By.CssSelector("[name=password_confirm]")).SendKeys(validPassword);
            webDriver.FindElement(By.CssSelector("[name=phone_number]")).SendKeys(validPhoneName);
            webDriver.FindElement(By.CssSelector("[class^=SignupForm__submitButton]")).Click();
            webDriver.FindElement(By.CssSelector("[name=company_name]")).SendKeys(companyName);
            webDriver.FindElement(By.CssSelector("[name=company_website]")).SendKeys(companyWebsite);
            webDriver.FindElement(By.CssSelector("[name=location]")).SendKeys(validAdress);
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div[class ='pac-item']")));
            webDriver.FindElement(By.CssSelector("div[class ='pac-item']")).Click();
            webDriver.FindElement(By.CssSelector("[class^=Select__container]")).Click();
            webDriver.FindElement(By.CssSelector("[class^=Select__option]")).Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("[class^=SignupCompanyForm__submitButton]")));
            webDriver.FindElement(By.CssSelector("[class^=SignupCompanyForm__submitButton]")).Click();

            wait.Until(ExpectedConditions.UrlToBe("https://newbookmodels.com/explore"));

            webDriver.FindElement(By.CssSelector("[class^=AvatarClient__avatar]")).Click();
        }
 /// <summary>
 /// Wait for the given time till the URL to be
 /// </summary>
 /// <param name="urlText"></param>
 /// <param name="timeOutSeconds"></param>
 public static void WaitForUrlToBe(string urlText, TimeSpan timeOutSecs)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(DriverInstance.Instance, timeOutSecs);
         wait.Until(ExpectedConditions.UrlToBe(urlText));
         LoggerInstance.log.Info("Driver explicitly waits " + timeOutSecs + " seconds for url text to be " + "\"" + urlText + "\".");
     }
     catch (NoSuchElementException elementNotPresent)
     {
         LoggerInstance.log.Error(elementNotPresent.Message, elementNotPresent);
     }
     catch (WebDriverTimeoutException webdriverTimeOut)
     {
         LoggerInstance.log.Error(webdriverTimeOut.Message, webdriverTimeOut);
     }
     catch (TimeoutException timeOutEx)
     {
         LoggerInstance.log.Error(timeOutEx.Message, timeOutEx);
     }
     catch (Exception e)
     {
         LoggerInstance.log.Error(e.Message, e);
     }
 }
Beispiel #4
0
 public ResultPage ChangeLocalization()
 {
     LanguageButton.Click();
     wait.Until(ExpectedConditions.UrlToBe("https://pass.rw.by/en/?c=true"));
     Logger.Logger.Log.Debug("m.ChangeLocalization");
     return(new ResultPage(driver));
 }
        public static bool WaitingFor_UrlToBe(IWebDriver driver, PageAlias alias, TimeSpan timeOut)
        {
            var url  = RouteMapper.ConvertAliasToUrl(alias);
            var wait = new WebDriverWait(driver, timeOut);

            return(wait.Until(ExpectedConditions.UrlToBe(url)));
        }
        public void Method()
        {
            wait.Until(ExpectedConditions.TitleIs("webdriver - Поиск в Google"));
            wait.Until(ExpectedConditions.TitleContains("webdriver - Поиск в"));
            wait.Until(ExpectedConditions.UrlContains("login.php"));
            wait.Until(ExpectedConditions.UrlToBe("http://pagination.js.org/"));
            var regex = @"\d";

            wait.Until(ExpectedConditions.UrlMatches(regex));
            wait.Until(ExpectedConditions.AlertIsPresent());
            //В С# я не нашел  wait.Until(ExpectedConditions.NumberOfWindowsToBe());
            //нужно проверять то, что у элемента есть какой-то класс, вместо того, чтобы проверять стиль элемента.
            //как правило, разработчики не меняют стили напрямую, они присваивают классы.
            wait.Until(x => x.FindElement(By.CssSelector("locator")).GetAttribute("class").Contains("error"));
            wait.Until(ExpectedConditions.TextToBePresentInElement(element, "text"));
            wait.Until(ExpectedConditions.ElementToBeSelected(element, false));
            wait.Until(ExpectedConditions.ElementToBeClickable(element));
            //ElementToBeClickable - не  соответствует своему названию. Сдесь проверяется то, что
            //елемент 1.Видимый, 2.Не disabled. И конечно, здесь нет никаких проверок, что эта кнопка НЕ ЗАКРЫТА никаким другим
            //элементом а если она прозрачная, то она будет считаться невидимой. Так, что название этого метода просто напросто врет.
            //По-настоящему ИНТЕРАКТИВНОСТЬ ОНО НЕ ПРОВЕРЯЕТ.
            //условие количества элементов с локатором
            var elements = driver.FindElements(By.CssSelector("locator"));

            wait.Until(x => elements.Count == 10);
            //но здесь мы возвращаем коллекцию элементов.
            var returnedElements = wait.Until(x =>
            {
                var elements2 = x.FindElements(By.CssSelector("locaotr"));
                return(elements2.Count == 10 ? elements2 : null);
            });
            //хз что это...
            var wait2 = new DefaultWait <IWebElement>(element);
        }
Beispiel #7
0
        public void Registration_ShouldRegisterUserIfInputValidData()
        {
            webDriver.Navigate().GoToUrl("https://newbookmodels.com/join");
            WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(5));

            webDriver.FindElement(By.CssSelector("[name^=first_name]")).SendKeys(validFirstName);
            webDriver.FindElement(By.CssSelector("[name^=last_name]")).SendKeys(validLastName);
            webDriver.FindElement(By.CssSelector("[name^=email]")).SendKeys(validemail);
            webDriver.FindElement(By.CssSelector("[name=password]")).SendKeys(validPassword);
            webDriver.FindElement(By.CssSelector("[name=password_confirm]")).SendKeys(validPassword);
            webDriver.FindElement(By.CssSelector("[name=phone_number]")).SendKeys(validPhoneName);
            webDriver.FindElement(By.CssSelector("[class^=SignupForm__submitButton]")).Click();
            webDriver.FindElement(By.CssSelector("[name=company_name]")).SendKeys(companyName);
            webDriver.FindElement(By.CssSelector("[name=company_website]")).SendKeys(companyWebsite);
            webDriver.FindElement(By.CssSelector("[name=location]")).SendKeys(validAdress);
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("div[class ='pac-item']")));
            webDriver.FindElement(By.CssSelector("div[class ='pac-item']")).Click();
            webDriver.FindElement(By.CssSelector("[class^=Select__container]")).Click();
            webDriver.FindElement(By.CssSelector("[class^=Select__option]")).Click();
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("[class^=SignupCompanyForm__submitButton]")));
            webDriver.FindElement(By.CssSelector("[class^=SignupCompanyForm__submitButton]")).Click();


            wait.Until(ExpectedConditions.UrlToBe("https://newbookmodels.com/explore"));
            var actualUrl = webDriver.Url;

            Assert.AreEqual("https://newbookmodels.com/explore", actualUrl);
        }
Beispiel #8
0
        public void ChangePassword_ShouldChangePassword()
        {
            WebDriverWait wait = new WebDriverWait(webDriver, TimeSpan.FromSeconds(10));

            webDriver.FindElement(By.CssSelector("nb-account-info-password .edit-switcher__icon_type_edit")).Click();
            var inputPasswordField = webDriver.FindElement(By.CssSelector("input[placeholder^=\"Enter Current Password\"]"));

            inputPasswordField.Clear();
            inputPasswordField.SendKeys(validPassword);

            var inputNewPasswordField = webDriver.FindElements(By.CssSelector("input[placeholder^=\"Enter New Password\"]"))[0];

            inputNewPasswordField.Clear();
            inputNewPasswordField.SendKeys(validNewPassword);

            var inputNewPasswordConfirmField = webDriver.FindElements(By.CssSelector("input[placeholder^=\"Enter New Password\"]"))[1];

            inputNewPasswordConfirmField.Clear();
            inputNewPasswordConfirmField.SendKeys(validNewPassword);

            webDriver.FindElement(By.CssSelector("nb-account-info-password .button")).Click();
            Thread.Sleep(2000);

            webDriver.FindElement(By.CssSelector("[type^=logout]")).Click();
            wait.Until(ExpectedConditions.UrlToBe("https://newbookmodels.com/auth/signin"));

            webDriver.FindElement(By.CssSelector("input[type=email]")).SendKeys(validemail);
            webDriver.FindElement(By.CssSelector("input[type=password]")).SendKeys(validNewPassword);
            webDriver.FindElement(By.CssSelector("[class^=SignInForm__submitButton]")).Click();

            var actualTitle = webDriver.FindElement(By.CssSelector("[class^=Section__title]"));

            Assert.AreEqual("Welcome back Dylan! How can we help?", actualTitle.Text.Trim());
        }
        public void ThenIWillLandOnTheArticlePageFor(string articleName)
        {
            var expectedArticleUrl = $"{_settingsUtility.BaseUrl}{_settingsUtility.ArticleRoute}/{articleName}";

            new WebDriverWait(_driver, TimeSpan.FromSeconds(2)).Until(ExpectedConditions.UrlToBe(expectedArticleUrl));
            _driver.Url.Should().Be(expectedArticleUrl);
        }
Beispiel #10
0
                    public void Search()
                    {
                        driver.Navigate().GoToUrl("http://google.com/ncr");

                        driver.FindElement(By.Name("q")).SendKeys("Selenide" + Keys.Enter);

                        /*
                         * new WebDriverWait(driver, TimeSpan.FromSeconds(2))
                         *  .Until(
                         *      ExpectedConditions.TextToBePresentInElement(
                         *          new GooglePage(driver).Results[0],
                         *          "Selenide: concise UI tests in Java"
                         *      )
                         *  );
                         */
                        new WebDriverWait(driver, TimeSpan.FromSeconds(2))
                        .Until(
                            CustomConditions.ListNthElementHasText(
                                new GooglePage(driver).Results,
                                0,
                                "Selenide: concise UI tests in Java"
                                )
                            );

                        driver.FindElements(By.CssSelector(".srg>.g"))[0]
                        .FindElement(By.CssSelector("h3>a")).Click();
                        new WebDriverWait(driver, TimeSpan.FromSeconds(2)).Until(
                            ExpectedConditions.UrlToBe("http://selenide.org/"));
                    }
 public AdminHomePage CorrectLogin(string user, string password)
 {
     usernameInput.SendKeys(user);
     passwordInput.SendKeys(password);
     loginButton.Click();
     wait.Until(ExpectedConditions.UrlToBe("http://localhost/litecart/admin/"));
     return(new AdminHomePage(driver));
 }
Beispiel #12
0
 // Проверка url страницы после авторизации
 // Верный логин и пароль, нажатие на кнопку, чекбокс не отмечен
 public void ValidLoginAndButtonClickRedirectsToDashboard()
 {
     driver.Url = loginPage;
     driver.FindElement(By.Name("username")).SendKeys("admin");
     driver.FindElement(By.Name("password")).SendKeys("admin");
     driver.FindElements(By.Name("login")).Last().Click();
     wait.Until(ExpectedConditions.UrlToBe(dashboardPage));
 }
Beispiel #13
0
 // Проверка url страницы после авторизации
 // Верный логин и пароль, нажатие enter, чекбокс не отмечен
 public void ValidLoginAndEnterRedirectToDashboard()
 {
     driver.Url = loginPage;
     driver.FindElement(By.Name("username")).SendKeys("admin");
     driver.FindElement(By.Name("password")).SendKeys("admin");
     driver.FindElement(By.Name("password")).SendKeys(Keys.Enter);
     wait.Until(ExpectedConditions.UrlToBe(dashboardPage));
 }
        public void ThenIWillBeRedirectedToTheHomePage()
        {
            var expectedHomePageUrl = $"{_settingsUtility.BaseUrl}/";

            new WebDriverWait(_driver, TimeSpan.FromSeconds(2)).Until(ExpectedConditions.UrlToBe(expectedHomePageUrl));

            _driver.Url.Should().Be(expectedHomePageUrl);
        }
Beispiel #15
0
 private void Login()
 {
     driver.Url = $"{adminPage}login.php";
     driver.FindElement(By.Name("username")).SendKeys("admin");
     driver.FindElement(By.Name("password")).SendKeys("admin");
     driver.FindElement(By.ClassName("btn")).Click();
     wait.Until(ExpectedConditions.UrlToBe(adminPage));
 }
Beispiel #16
0
 // Проверка url страницы после авторизации
 // НЕверный логин и пароль, нажатие на кнопку, чекбокс не отмечен
 public void InvalidLoginAndButtonClickDoesNotRedirectsToDashboard(string login, string password)
 {
     driver.Url = loginPage;
     driver.FindElement(By.Name("username")).SendKeys(login);
     driver.FindElement(By.Name("password")).SendKeys(password);
     driver.FindElements(By.Name("login")).Last().Click();
     wait.Until(ExpectedConditions.UrlToBe(loginPage));
 }
Beispiel #17
0
 // Проверка url страницы после авторизации
 // НЕверный логин и пароль, нажатие enter, чекбокс отмечен
 public void InvalidLoginCheckBoxAndEnterDoesNotRedirectsToDashboard(string login, string password)
 {
     driver.Url = loginPage;
     driver.FindElement(By.Name("username")).SendKeys(login);
     driver.FindElement(By.Name("password")).SendKeys(password);
     driver.FindElement(By.Name("remember_me")).Click();
     driver.FindElement(By.Name("password")).SendKeys(Keys.Enter);
     wait.Until(ExpectedConditions.UrlToBe(loginPage));
 }
Beispiel #18
0
        public void CheckRedirectTOLoginPage()
        {
            Driver.Navigate().GoToUrl(mainPageUrl);

            (new WebDriverWait(Driver, TimeSpan.FromSeconds(10))).
            Until(ExpectedConditions.UrlToBe(loginPageUrl));

            Assert.AreEqual(Driver.Url, loginPageUrl, "Неверный редирект");
        }
Beispiel #19
0
 public static void WaitForUrl(IWebDriver driver, String url, int TimeoutInSecs = 10)
 {
     new WebDriverWait(
         driver,
         TimeSpan.FromSeconds(TimeoutInSecs)
         ).Until(
         ExpectedConditions.UrlToBe(url)
         );
 }
Beispiel #20
0
                    public void FollowFirstLink()
                    {
                        driver.Navigate().GoToUrl("http://google.com/ncr");
                        driver.FindElement(By.Name("q")).SendKeys("Selenide" + Keys.Enter);

                        driver.FindElements(By.CssSelector(".srg>.g"))[0]
                        .FindElement(By.CssSelector("h3>a")).Click();
                        new WebDriverWait(driver, TimeSpan.FromSeconds(2)).Until(
                            ExpectedConditions.UrlToBe("http://selenide.org/"));
                    }
        public void GivenIAmSignedInWithEmailAndPasswordEndToEnd(string email, string password)
        {
            _signInPage = SignInPage.NavigateTo(_driver, _settingsUtility);
            _signInPage.EnterDataIntoField(_signInPage.EmailInput, email);
            _signInPage.EnterDataIntoField(_signInPage.PasswordInput, password);
            _signInPage.SignInButton.Click();
            var expectedHomePageUrl = $"{_settingsUtility.BaseUrl}/";

            new WebDriverWait(_driver, TimeSpan.FromSeconds(2)).Until(ExpectedConditions.UrlToBe(expectedHomePageUrl));
        }
Beispiel #22
0
        public void ClickOnMobileOption(string linkMobile)
        {
            IWebElement mobileOption = _driver.FindElement(By.LinkText(linkMobile));

            //Thread.Sleep(5000);
            _wait.Until(ExpectedConditions.UrlToBe("http://live.guru99.com/index.php/mobile.html"));

            mobileOption.Click();
            Console.WriteLine("The option selected is: " + linkMobile);
            Thread.Sleep(5000);
        }
Beispiel #23
0
        public void WaitTillUrlToBe(string url, int seconds = 60)
        {
            try
            {
                var wait = new WebDriverWait(_nativeWebDriver, TimeSpan.FromSeconds(seconds));
                wait.Until(ExpectedConditions.UrlToBe(url));
            }

            catch (Exception ex)
            {
                throw new WaitForElementException("URL", url, ex);
            }
        }
Beispiel #24
0
        public void AuthorizationWithCorrectLoginAndPassword()
        {
            //Driver.Manage().Timeouts().PageLoad = TimeSpan.FromSeconds(20);
            LoginPage loginPage = new LoginPage(Driver);

            loginPage.GoToLoginPage();
            loginPage.Submit("qaaestimateadmin", "qa1234");

            (new WebDriverWait(Driver, TimeSpan.FromSeconds(10))).
            Until(ExpectedConditions.UrlToBe(estimatesPageUrl));

            Assert.AreEqual(Driver.Url, estimatesPageUrl, "Неверный редирект");
        }
Beispiel #25
0
        public static void Init(TestContext context)
        {
            var app = new WebApplication(ProjectLocation.FromFolder("Fundraise.MvcExample"), 12365);

            WebServer = new IisExpressWebServer(app);
            WebServer.Start();
            Browser = new FirefoxDriver();

            // Create a test user
            Browser.Manage().Window.Maximize();
            Browser.Navigate().GoToUrl("http://localhost:12365/Account/Register");

            var emailBox = Browser.FindElementById("Email");

            emailBox.SendKeys(email);

            var passwordBox = Browser.FindElementById("Password");

            passwordBox.SendKeys("test1234");

            var confirmPasswordBox = Browser.FindElementById("ConfirmPassword");

            confirmPasswordBox.SendKeys("test1234");

            var submitButton = Browser.FindElementById("RegisterSubmit");

            submitButton.Submit();

            try
            {
                var wait    = new WebDriverWait(Browser, TimeSpan.FromSeconds(10));
                var element = wait.Until(ExpectedConditions.UrlToBe("http://localhost:59702/"));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception while waiting for 'Edit' link: " + ex.Message);
                Console.WriteLine("Final URL was " + Browser.Url);
                var screenshot2 = Browser.GetScreenshot();
                screenshot2.SaveAsFile("login-error.png");
                if (Browser.PageSource.IndexOf("<code><pre>") > 0)
                {
                    Console.WriteLine(Browser.PageSource.Substring(Browser.PageSource.IndexOf("<code><pre>")));
                }
                else
                {
                    Console.WriteLine("Final page title was: " + Browser.Title);
                }
            }
            Console.WriteLine("complete ClassInitialize");
        }
 public bool UnidadMedidaClick()
 {
     try
     {
         IWebElement el = driver.FindElementByCssSelector("[href*='Mantenimientos/MantenimientoUnidadMedida.aspx']");
         el.Click();
         wait.Until(ExpectedConditions.UrlToBe("http://localhost:62008/Mantenimientos/MantenimientoUnidadMedida.aspx"));
         return(true);
     }
     catch (OpenQA.Selenium.StaleElementReferenceException ex)
     {
         return(false);
     }
 }
Beispiel #27
0
                    public void Search()
                    {
                        driver.Navigate().GoToUrl("http://google.com/ncr");

                        driver.FindElement(By.Name("q")).SendKeys("Selenide" + Keys.Enter);
                        StringAssert.Contains("Selenide: concise UI tests in Java",
                                              driver.FindElement(By.CssSelector(".srg>.g:nth-of-type(1)"))
                                              .Text
                                              );

                        driver.FindElements(By.CssSelector(".srg>.g"))[0]
                        .FindElement(By.CssSelector("h3>a")).Click();
                        new WebDriverWait(driver, TimeSpan.FromSeconds(2)).Until(
                            ExpectedConditions.UrlToBe("http://selenide.org/"));
                    }
Beispiel #28
0
        public void BeautyClick()
        {
            Initializer.Driver.Scripts().ExecuteScript("arguments[0].click();", BeautyRef);
            string currentTab = Initializer.Driver.CurrentWindowHandle;

            foreach (string tab in Initializer.Driver.WindowHandles)
            {
                if (!tab.Equals(currentTab))
                {
                    Initializer.Driver.SwitchTo().Window(tab);
                }
            }
            WebDriverWait wait = new WebDriverWait(Initializer.Driver, TimeSpan.FromSeconds(3));

            wait.Until(ExpectedConditions.UrlToBe("https://www.instagram.com/topics/beauty/"));
        }
Beispiel #29
0
        public void LoginTests_Github()
        {
            driver.Navigate().GoToUrl(TestingUrl);

            driver.FindElement(By.CssSelector(".navbar-nav")).Click();
            wait.Until(ExpectedConditions.UrlToBe(LoginUrl));

            driver.FindElement(By.CssSelector(".github-login")).Click();
            wait.Until(ExpectedConditions.UrlContains("https://github.com/login"));

            driver.FindElement(By.Id("login_field")).SendKeys(Secrets.GithubUsername);
            driver.FindElement(By.Id("password")).SendKeys(Secrets.GithubPassword);
            driver.FindElement(By.CssSelector("input[type=submit]")).Click();

            wait.Until(ExpectedConditions.UrlToBe(AppsUrl));
        }
Beispiel #30
0
        public void Login(string username, string password)
        {
            /* Enter Username and password */
            txt_UserName.SendKeys(username);
            txt_Password.SendKeys(password);
            btn_login.Click();

            /* Wait until page completly loads */
            WebDriverWait wait = new WebDriverWait(Browser.wdriver, TimeSpan.FromSeconds(150));

            wait.Until(ExpectedConditions.UrlToBe(DashBoardURL));

            /* Assert page title and page URL after login */
            Assert.AreEqual(DashBoardURL, Browser.wdriver.Url);
            Assert.AreEqual("Live Testing Project.", Browser.wdriver.Title);
        }