예제 #1
0
파일: LoginTest.cs 프로젝트: elkemper/Appul
        public void WrongLogin(IWebDriver driver)
        {
            string _wrongusermail = "*****@*****.**";
            string _wronguserpass = "******";

            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(20));
            driver.Navigate().GoToUrl(LoginURL);

            IWebElement useremail    = driver.FindElement(By.Id("email"));
            IWebElement userpassword = driver.FindElement(By.Id("password"));
            IWebElement submitBttn   = driver.FindElement(By.ClassName("signin-button"));

            var halt = new WebDriverWait(driver, TimeSpan.FromSeconds(5));

            Driver.FocusElement(driver, useremail);
            useremail.Clear();
            useremail.SendKeys(_wrongusermail);

            halt.Until(ExpectedConditions.TextToBePresentInElementValue(useremail, _wrongusermail));
            Driver.FocusElement(driver, userpassword);
            userpassword.Clear();
            userpassword.SendKeys(_wronguserpass);
            submitBttn.Click();

            Thread.Sleep(500);

            const string expectUrl = LoginURL;

            Assert.AreEqual(expectUrl, driver.Url, "Smthn changed");

            Assert.IsTrue(driver.FindElement(By.ClassName("validation-summary-errors")).Enabled, "Email-missing warning disabled");

            driver.Dispose();
        }
예제 #2
0
        public void MultiCheckButtonName(string multiButtonText)
        {
            WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.TextToBePresentInElementValue(_multiCheckBoxResult, multiButtonText));
            Assert.AreEqual(multiButtonText, _multiCheckBoxResult.GetAttribute("value"), "MultiBox mygtuko textas nesutampa");
        }
        public void FillLocationOfEvent(string location)
        {
            wait.Until(ExpectedConditions.ElementIsVisible(By.CssSelector("#location")));
            wait.Until(ExpectedConditions.ElementToBeClickable(By.CssSelector("#location")));
            bool      textNotEntered = true;
            Stopwatch timer          = new Stopwatch();

            timer.Start();
            while (textNotEntered)
            {
                locationOfEvent.SendKeys(location);
                try
                {
                    wait.Until(ExpectedConditions.TextToBePresentInElementValue(locationOfEvent, location));
                    textNotEntered = false;
                }
                catch (WebDriverTimeoutException t)
                {
                    locationOfEvent.Clear();
                }
                if (timer.Elapsed.Seconds > 10)
                {
                    textNotEntered = false;
                    ReportLog.Fail("Couldn't input location.");
                    throw new WebDriverTimeoutException("Couldn't input location.");
                }
            }
            Assert.AreEqual(location, locationOfEvent.GetAttribute("value"));
            ReportLog.Log("Filled location of event as: " + location);
        }
예제 #4
0
        public BasicCheckboxDemoPage AssertButtonName(string expectedName)
        {
            GetWait(7).Until(ExpectedConditions.TextToBePresentInElementValue(_checkAllButton, "Uncheck All"));

            Assert.AreEqual(expectedName, _checkAllButton.GetAttribute("value"), "Wrong button label");
            return(this);
        }
        public void T04_EditMeasureUnit()
        {
            //Edit the data of a testing element

            IWebElement searchForm = driver.FindElementByClassName("input-sm");

            searchForm.Clear();
            searchForm.SendKeys("botella");

            wait.Until(ExpectedConditions.TextToBePresentInElementValue(searchForm, "Botella"));
            IWebElement next_button = driver.FindElementById("gridUnidadMedida_next");


            ReadOnlyCollection <IWebElement> edit_buttons = driver.FindElementsByClassName("btn-xs");

            foreach (IWebElement edit_button in edit_buttons)
            {
                if (edit_button.GetAttribute("onclick").Contains("botella"))
                {
                    System.Diagnostics.Trace.WriteLine(edit_button.Text);
                    wait.Until(ExpectedConditions.ElementToBeClickable(edit_button));
                    //   wait.Until(ExpectedConditions.AlertIsPresent());
                    edit_button.Click();
                }
            }


            /*
             * <a onclick="ShowUpdateModal(9,'Botella','bt')" class="btn btn-warning btn-xs">Editar</a>
             */
        }
예제 #6
0
        public void FF_GoogleSearch()
        {
            using (var driver = new FirefoxDriver())
            {
                string searchKey = "selenium";
                driver.Manage().Window.Maximize();
                driver.Url = "https://www.google.ro";

                var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                var obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.Id("lst-ib")));
                obj.SendKeys(searchKey + Keys.Tab);
                wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));
                wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("lst-ib"), searchKey));

                wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//input[@name='btnK']")));
                obj.Click();

                wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
                obj  = wait.Until(ExpectedConditions.ElementToBeClickable(By.XPath(".//h3/a")));
                string url = obj.GetAttribute("href");
                driver.Navigate().GoToUrl(url);

                // checking the page title
                string title   = driver.Title;
                bool   titleOk = title.Contains("Selenium");
                Assert.That(titleOk, Is.True);

                driver.Quit();
            } //
        }     // GoogleSearch
        public void testLocal()
        {
            IOSElement testButton = (IOSElement) new WebDriverWait(driver, TimeSpan.FromSeconds(30)).Until(ExpectedConditions.ElementToBeClickable(MobileBy.AccessibilityId("TestBrowserStackLocal")));

            testButton.Click();

            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(30));

            wait.Until(ExpectedConditions.TextToBePresentInElementValue(driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal")), "Response is: Up and running"));
            IOSElement resultElement = (IOSElement)driver.FindElement(MobileBy.AccessibilityId("ResultBrowserStackLocal"));

            String resultString = resultElement.Text.ToLower();

            if (resultString.Contains("not working"))
            {
                Screenshot ss                    = ((ITakesScreenshot)driver).GetScreenshot();
                string     screenshot            = ss.AsBase64EncodedString;
                byte[]     screenshotAsByteArray = ss.AsByteArray;
                ss.SaveAsFile("screenshot", ScreenshotImageFormat.Png);
                ss.ToString();
            }

            String expectedString = "Up and running";

            Assert.True(resultString.Contains(expectedString.ToLower()));
        }
        public void FirstTest()
        {
            const string text = "selenium", textBoxlocator = "lst-ib";

            driver.FindElement(By.Id(textBoxlocator)).SendKeys(text + Keys.Enter);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id(textBoxlocator), text));
        }
        public void AddAttachment(string strFullFilePath, string strFilename)
        {
            if (!strFullFilePath.Equals("") && !strFilename.Equals(""))
            {
                try
                {
                    if (null != _attachFile)
                    {
                        _attachFile.SendKeys(strFullFilePath);
                        _actionsBuilder.SendKeys(Keys.Enter);

                        By attachmentInfo = By.XPath($"//input[contains(@value,'{strFilename}')]");
                        _isAttachmentComplete = _wait.Until(ExpectedConditions.TextToBePresentInElementValue(attachmentInfo, strFilename));

                        ProcessUtils.ConsoleLog($"Attach File Complete: {_isAttachmentComplete}");
                    }
                    else
                    {
                        ProcessUtils.ConsoleLog("ERROR: Input Attach File Path Not Found");
                    }
                }
                catch (WebDriverTimeoutException timeout)
                {
                    ProcessUtils.ConsoleLog(timeout.Message);
                }
            }
            else
            {
                ProcessUtils.ConsoleLog("No ATTACHMENT provided");
            }
        }
예제 #10
0
파일: LoginTest.cs 프로젝트: elkemper/Appul
        public void CorrectLogin(IWebDriver driver)
        {
            string _usermail = "*****@*****.**";
            string _userpass = "******";

            driver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(20));
            driver.Navigate().GoToUrl(LoginURL);
            IWebElement useremail    = driver.FindElement(By.Id("email"));
            IWebElement userpassword = driver.FindElement(By.Id("password"));
            IWebElement submitBttn   = driver.FindElement(By.ClassName("signin-button"));

            var halt = new WebDriverWait(driver, TimeSpan.FromSeconds(5));

            Driver.FocusElement(driver, useremail);
            useremail.Clear();
            useremail.SendKeys(_usermail);

            halt.Until(ExpectedConditions.TextToBePresentInElementValue(useremail, _usermail));
            Driver.FocusElement(driver, userpassword);
            userpassword.Clear();
            userpassword.SendKeys(_userpass);
            submitBttn.Click();

            //chrome driver is too fast, and don'wanna wait for onload w\out that
            halt.Until(ExpectedConditions.ElementIsVisible(By.ClassName("logout-icon")));

            const string expectUrl = LoggedURL;

            Assert.AreEqual(expectUrl, driver.Url, "Logging is incomplete");
            Assert.AreEqual(driver.FindElement(By.ClassName("first-name")).Text, "David", "First name is wrong");
            Assert.AreEqual(driver.FindElement(By.ClassName("last-name")).Text, "Smith", "Last name is wrong");
        }
 /// <summary>
 /// Wait for the value of the element to be given text for given timeout
 /// </summary>
 /// <param name="element"></param>
 /// <param name="urlText"></param>
 /// <param name="timeOutSeconds"></param>
 public static void WaitForElementTextValue(IWebElement element, string textValue, TimeSpan timeOutSecs)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(DriverInstance.Instance, timeOutSecs);
         wait.Until(ExpectedConditions.TextToBePresentInElementValue(element, textValue));
         LoggerInstance.log.Info("Driver explicitly waits " + timeOutSecs + " seconds for web element text value to be" + "\"" + textValue + "\".");
     }
     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);
     }
 }
예제 #12
0
        public MultipleCheckBoxPage AssertButtonName(string expectedName)
        {
            GetWait().Until(ExpectedConditions.TextToBePresentInElementValue(_checkAllButton, expectedName));

            Assert.AreEqual(expectedName, _checkAllButton.GetAttribute("value"), "Wrong button label");

            return(this);
        }
예제 #13
0
 public void Continuar(string botao)
 {
     wait.Until(ExpectedConditions.ElementIsVisible(By.Id("btnSalvar")));
     wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("btnSalvar"), botao));
     Thread.Sleep(1000);
     driver.FindElement(By.Id("btnSalvar")).Click();
     wait.Until(ExpectedConditions.ElementIsVisible(By.ClassName("icone-plano")));
 }
예제 #14
0
        public CheckBoxPage AssertButtonName(string expectedName)
        {
            WebDriverWait wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(10));                    // 5 sek neuzteko

            wait.Until(ExpectedConditions.TextToBePresentInElementValue(_checkAllButton, expectedName)); // norim palaukti kol tekstas atsiras mygtuke; button'as turi atributa value, todel renkames TextToBePresentInElementValue; ExpectedConditions pabraukta zaliai, nes bus ateityje panaikinta, bet kol kas palaikoma?
            Assert.AreEqual(expectedName, _checkAllButton.GetAttribute("value"), "Wrong button label");
            return(this);
        }
예제 #15
0
        public void SearchForBook(string book_name)
        {
            var wait = new WebDriverWait(driver, TimeSpan.FromSeconds(15));

            wait.Until(ExpectedConditions.ElementExists(iptSearch));
            Search_Book().SendKeys(book_name);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(Search_Book(), book_name));
            BtnSearch().Click();
        }
예제 #16
0
 public void LocalidadeImovel(string cep, string endereco, string carregaendereco, string num, string complemento)
 {
     driver.FindElement(By.Id("txtCepImovel")).SendKeys(cep);
     driver.FindElement(By.Id("txtCepImovel")).SendKeys(Keys.Tab);
     wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("txtLogradouro"), carregaendereco));
     driver.FindElement(By.Id("txtLogradouro")).SendKeys(endereco);
     driver.FindElement(By.Id("txtNumero")).SendKeys(num);
     driver.FindElement(By.Id("txtComplemento")).SendKeys(complemento);
 }
        public void SetEventDate(string date)
        {
            eventDate.SendKeys(date);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(eventDate, date));
            var dateValue = eventDate.GetAttribute("value");

            Assert.AreEqual(date, dateValue);
            ReportLog.Log("Set event date as: " + date);
        }
        public void Login()
        {
            //Navigate to the login page and try to login with an invalid user and password
            driver.Navigate().GoToUrl(baseURL);
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(5));

            //Find username form
            IWebElement username = driver.FindElementById("TextBoxUsername");

            username.Clear();
            username.SendKeys("*****@*****.**");
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("TextBoxUsername"), "*****@*****.**"));


            //Find password form
            IWebElement password = driver.FindElementById("TextBoxPassword");

            password.Clear();
            password.SendKeys("blahblah");
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("TextBoxPassword"), "blahblah"));

            IWebElement login_button = driver.FindElementById("ButtonLogin");

            login_button.Click();
            Assert.IsTrue(isAlertPresent(), "Test failed. It should display an alert");
            driver.SwitchTo().Alert().Accept();


            //Try to login with a valid user but without a password
            username = driver.FindElementById("TextBoxUsername");
            username.Clear();
            username.SendKeys("*****@*****.**");

            password = driver.FindElementById("TextBoxPassword");
            password.Clear();

            login_button = driver.FindElementById("ButtonLogin");
            login_button.Click();

            Assert.AreEqual(driver.Url, baseURL);


            //Login using a valid username and password
            username = driver.FindElementById("TextBoxUsername");
            username.Clear();
            username.SendKeys("SA");

            password = driver.FindElementById("TextBoxPassword");
            password.Clear();
            password.SendKeys("airdogs");

            login_button = driver.FindElementById("ButtonLogin");
            login_button.Click();

            Assert.AreEqual(driver.Url, "http://localhost:62008/Test.aspx");
        }
예제 #19
0
        /// <summary>
        ///     Use IWebDriver Wait to determine if object contains the expected text
        /// </summary>
        /// <param name="element">The element for which to search</param>
        /// <param name="driver">The IWebDriver</param>
        /// <param name="text">Text for which to search</param>
        /// <returns>Boolean true if the text is present in the element, false otherwise</returns>
        public Boolean webElementTextPresent(Tuple <locatorType, string> element, IWebDriver driver,
                                             string text)
        {
            //Define a new WebDriverWait object, defined in part by the driver, which will be used to wait for a condition to be met
            WebDriverWait wait    = new WebDriverWait(driver, TimeSpan.FromSeconds(0));
            Boolean       present = false;

            try
            {
                //Determine if the text is present in the actual element
                if (wait.Until(ExpectedConditions.TextToBePresentInElement(findElement(element), text)))
                {
                    present = true;
                }
                //Determine if the text is present in the element attribute 'Value'
                else if (wait.Until(ExpectedConditions.TextToBePresentInElementValue(findElement(element), text)))
                {
                    present = true;
                }
                else
                {
                    present = false;
                }
            }
            catch (Exception ex)
            {
                //If an the element is not found, the element is stale or a timeout occurs...
                if (ex is NoSuchElementException || ex is StaleElementReferenceException || ex is TimeoutException)
                {
                    try
                    {
                        //Determine if the text is present in the element attribute 'Value'
                        if (wait.Until(ExpectedConditions.TextToBePresentInElementValue(findElement(element), text)))
                        {
                            present = true;
                        }
                        else
                        {
                            present = false;
                        }
                    }
                    catch (Exception exc)
                    {
                        //If an the element is not found, the element is stale or a timeout occurs, the element is deemed not present
                        if (exc is NoSuchElementException || exc is StaleElementReferenceException || exc is TimeoutException)
                        {
                            present = false;
                        }
                    }
                }
            }

            return(present);
        }
예제 #20
0
 public void WaitForTextToBePresentInElementValue(By selector, string text, int timeout = 5)
 {
     try
     {
         GetWebDriverWait(timeout).Until(ExpectedConditions.TextToBePresentInElementValue(selector, text));
     }
     catch (NoSuchElementException e)
     {
         Logger.Log.Error(e);
         throw;
     }
 }
예제 #21
0
        public void autoPreenchimentoDeCampos(string cep, string numero, string complemento)
        {
            // Encontrando campo CEP e preenchendo-o
            IWebElement campoCEP = driver.FindElement(By.Id("cep"));

            campoCEP.SendKeys(cep);

            // Encontrando campo numero e preenchendo-o
            IWebElement campoNumero = driver.FindElement(By.Id("numero"));

            campoNumero.Click();
            campoNumero.SendKeys(numero);

            // Encontrando campo complemento e preenchendo-o
            IWebElement campoComplemento = driver.FindElement(By.Id("complemento"));

            campoComplemento.SendKeys(complemento);

            // Aguardando preenchimento automático do campo rua
            WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));

            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("rua"), "Avenida: Paulista"));

            // Armazenar os dados do campo CEP
            cepPreenchido = Convert.ToString(campoCEP.GetAttribute("value"));

            // Armazenar os dados do campo Numero
            numeroPreenchido = Convert.ToString(campoNumero.GetAttribute("value"));

            // Armazenar os dados do campo Complemento
            complementoPreenchido = Convert.ToString(campoComplemento.GetAttribute("value"));

            // Encontrando e Armazenar os dados do campo Rua
            IWebElement campoRua = driver.FindElement(By.Id("rua"));

            ruaPreenchida = Convert.ToString(campoRua.GetAttribute("value"));

            // Encontrando e Armazenar os dados do campo Bairro
            IWebElement campoBairro = driver.FindElement(By.Id("bairro"));

            bairroPreenchido = Convert.ToString(campoBairro.GetAttribute("value"));

            // Encontrando e Armazenar os dados do campo Cidade
            IWebElement campoCidade = driver.FindElement(By.Id("cidade"));

            cidadePreenchida = Convert.ToString(campoCidade.GetAttribute("value"));

            // Encontrando e Armazenar os dados do campo Estado
            IWebElement campoEstado = driver.FindElement(By.Id("estado"));

            estadoPreenchido = Convert.ToString(campoEstado.GetAttribute("value"));
        }
예제 #22
0
        public void ExplicitWait()
        {
            _driver.Url = BaseUrl + "SimpleDemo.2.html";

            var button = _driver.FindElement(By.Id("myButton"));
            var input  = _driver.FindElement(By.Id("myInput"));

            button.Click();
            var wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(10));     // change to 1 second to see it fail
            var done = wait.Until(ExpectedConditions.TextToBePresentInElementValue(input, "Done"));

            Assert.IsTrue(done);
        }
예제 #23
0
 /// <summary>
 /// Element Appear
 /// </summary>
 public void untilTextToBePresent(By by, String text)
 {
     try
     {
         log.Info(by + " ilgili elementte değerin yazılması bekleniyor...");
         wait.Until(ExpectedConditions.TextToBePresentInElementValue(by, text));
     }
     catch (Exception e)
     {
         log.Error(e.Message, e);
         assertFail(by.ToString() + " bulunamadı");
     }
 }
예제 #24
0
        public void Create_ChoosingACompany_PopulatesForm()
        {
            SelectElement CompanyNameSelect = new SelectElement(_driver.FindElement(By.Id("CompanyName")));

            _page.CompanyNameSelect.SelectByText("Google");

            WebDriverWait wait = new WebDriverWait(_driver, TimeSpan.FromSeconds(5));

            wait.Until(ExpectedConditions.TextToBePresentInElementValue(_page.LocationElement, "Warsaw"));
            Assert.Equal("Warsaw", _page.LocationElement.GetAttribute("value"));
            Assert.Equal("40", _page.HoursWeeklyElement.GetAttribute("value"));
            Assert.Equal("20", _page.RemoteHoursWeeklyElement.GetAttribute("value"));
        }
예제 #25
0
        public void ThenNomeDoTitularAceitaLetrasEEspacos_()
        {
            var texto = DataGenerator.RandomString(5) + " " +
                        DataGenerator.RandomString(5);

            _webDriver.Wait
            .Until(ExpectedConditions.ElementIsVisible(
                       By.Id("creditcard-owner")))
            .SendKeys(texto);

            Assert.True(_webDriver.Wait
                        .Until(ExpectedConditions.TextToBePresentInElementValue(
                                   By.Id("creditcard-owner"), texto)));
        }
예제 #26
0
 /// <summary>
 /// Waits for text to be present in the web element attribute value.
 /// </summary>
 /// <param name="driver">the <see cref="IWebDriver"/></param>
 /// <param name="element">the web element</param>
 /// <param name="expectedText">the expected text</param>
 /// <param name="elementName">the element name</param>
 /// <param name="page">the page name</param>
 public static void WaitForTextToBePresentInValue(IWebDriver driver, IWebElement element, String expectedText, String elementName, String page)
 {
     try
     {
         WebDriverWait wait = new WebDriverWait(driver, ConfigurationReader.FrameworkConfig.GetExplicitlyTimeout());
         wait.Until(ExpectedConditions.TextToBePresentInElementValue(element, expectedText));
         LogHandler.Info("WaitForTextToBePresentInValue:: The text: " + expectedText + " is not present in the element " + elementName + " on the page " + page);
     }
     catch (Exception e)
     {
         LogHandler.Error("WaitForTextToBePresentInValue::Exception - " + e.Message);
         throw new NoSuchElementException("WaitForTextToBePresentInValue::The text " + expectedText + " is not present in the element " + elementName + " on the page " + page);
     }
 }
예제 #27
0
        public void EnderecoDiferente(string cep, string endereco, string carregaendereco, string num, string complemento)
        {
            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("fldUsarNovoEnderecoFaturamento")));
            driver.FindElement(By.Id("fldUsarNovoEnderecoFaturamento")).Click();

            wait.Until(ExpectedConditions.ElementIsVisible(By.Id("DadosAnunciante_Endereco_CEP")));
            driver.FindElement(By.Id("DadosAnunciante_Endereco_CEP")).SendKeys(cep);
            driver.FindElement(By.Id("DadosAnunciante_Endereco_CEP")).SendKeys(Keys.Tab);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("DadosAnunciante_Endereco_Logradouro"), carregaendereco));
            driver.FindElement(By.Id("DadosAnunciante_Endereco_Logradouro")).SendKeys(endereco);
            driver.FindElement(By.Id("DadosAnunciante_Endereco_Numero")).SendKeys(num);
            driver.FindElement(By.Id("DadosAnunciante_Endereco_Complemento")).SendKeys(complemento);
            driver.FindElement(By.Id("DadosAnunciante_Endereco_Complemento")).SendKeys(Keys.Tab);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("DadosAnunciante_Endereco_Logradouro"), carregaendereco));
        }
        //[Test]
        public void WithoutWaits()
        {
            //неявные
            driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
            //явные
            wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Id("1234"), "444"));

            driver.Url = "https://www.google.com.ua";
            driver.FindElement(By.Name("q")).SendKeys("webdriver");
            var a = driver.FindElement(By.Name("btnG"));

            a.Click();
            Assert.IsTrue(IsElementPresentGood(driver, By.XPath("//*[contains(@class,'rc')]")));
        }
예제 #29
0
        public ResultPage Authorization(string login, string password)
        {
            SearchLogInIcon.Click();
            wait.Until(ExpectedConditions.ElementIsVisible(By.XPath("//div[@class='modal-content']/div[@class='auth-modal__header']")));

            Login.SendKeys(login);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Name("login"), "dpitalenko"));

            Password.SendKeys(password);
            wait.Until(ExpectedConditions.TextToBePresentInElementValue(By.Name("password"), "123456789rwby"));

            LogInButton.Click();
            wait.Until(ExpectedConditions.UrlToBe("https://pass.rw.by/ru/?path=ru%2F"));

            return(new ResultPage(driver));
        }
        public bool isTextPresentInValue(By locator, string value)
        {
            bool result = false;

            try
            {
                WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(Timeout));
                result = wait.Until(ExpectedConditions.TextToBePresentInElementValue(locator, value));
            }
            catch (TimeoutException)
            {
                Browser.CaptureError(driver, "timeout" + new DateTime().ToString("yyyyMMddhhmm") + ".jpg");
                throw;
            }
            return(result);
        }