Example #1
0
        /// <summary>
        /// The initiate <see cref="IWebElement"/>
        /// </summary>
        /// <param name="locator">
        /// The locator <see cref="By"/>.
        /// </param>
        /// <returns>
        /// The <see cref="IWebElement"/>.
        /// </returns>
        private IWebElement InitiateIWebElement(By locator)
        {
            var wait = new WebDriverWait(this.Driver, TimeSpan.FromSeconds(3.0));

            wait.Until(ExpectedConditions.ElementIsClickable(locator));
            return(this.Driver.FindElement(locator));
        }
Example #2
0
        public void LogInWithWrongDataTest(string login, string password)
        {
            GmailAboutPage aboutPage = null;

            try
            {
                aboutPage = new GmailAboutPage(AppDomain.CurrentDomain.BaseDirectory);
                var singInPage = aboutPage.GoToSingInPage();
                singInPage.InputLogin(login);
                singInPage.TypePassword(password);
                singInPage.PasswordInputElement.SendKeys(Keys.Enter);
                this.driver = singInPage.Driver;
                var wait = new WebDriverWait(this.driver, TimeSpan.FromSeconds(3.0));
                wait.Until(ExpectedConditions.ElementIsClickable(By.XPath("//div[contains(.,'Неверный')]")));
                Assert.IsTrue(this.driver.FindElement(
                                  By.XPath("//div[contains(.,'Неверный')]")).Displayed);
            }
            catch (WebDriverException e)
            {
                Console.WriteLine(e);
                throw;
            }
            finally
            {
                aboutPage.Driver.Quit();;
            }
        }
Example #3
0
        public static void ClickWithScrollToBottom(this IWebElement element, IWebDriver driver)
        {
            WebDriverWait       wait = new WebDriverWait(driver, TimeSpan.FromSeconds(AppConfig.Timeout));
            IJavaScriptExecutor javaScriptExecutor = (IJavaScriptExecutor)driver;

            javaScriptExecutor.ExecuteScript("window.scrollTo(0, document.body.scrollHeight);");
            wait.Until(ExpectedConditions.ElementIsClickable(element));
            element.Click();
        }
Example #4
0
        public static void ClickWithScroll(this IWebElement element, IWebDriver driver)
        {
            WebDriverWait       wait = new WebDriverWait(driver, TimeSpan.FromSeconds(AppConfig.Timeout));
            IJavaScriptExecutor javaScriptExecutor = (IJavaScriptExecutor)driver;

            wait.Until(ExpectedConditions.PageIsLoaded());
            javaScriptExecutor.ExecuteScript("arguments[0].scrollIntoView({ behavior: 'auto', block: 'center' });", element);
            wait.Until(ExpectedConditions.ElementIsClickable(element));
            element.Click();
        }