Android apps to use in appium android test examples

Breaking

Tuesday, March 13, 2018

WebDriver - human face for text to hold upward introduce amongst representative using explicit wait

Some times yous involve to wait for textwait for elementwait for element syntax inward our attempt case. Now allow nosotros encounter how tin move nosotros forcefulness webdriver to wait if expected text is not displayed on targeted chemical component subdivision of software spider web application page.

As yous know, nosotros tin move role "waitForText" or "waitForTextPresent" commands inward selenium IDE software testing tool to hold off till targeted text appears on page of software spider web application or element. In webdriver, nosotros tin move role syntax equally shown bellow.

WebDriverWait hold off = novel WebDriverWait(driver, 15); wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//div[@id='timeLeft']"), "Time left: seven seconds"));

Look inward to higher upward syntax. Here i bring used textToBePresentInElementLocated(By, String) to hold off till expected text appears on targeted element. So hither what WebDriver volition create is it volition banking concern agree for expected text on targeted chemical component subdivision on every 500 milliseconds in addition to volition execute side past times side pace equally shortly equally expected text appears on targeted element.

Run bellow given practical example.in eclipse in addition to encounter how it works.
Copy bellow given @Test method business office of hold off for text representative in addition to supervene upon it amongst the @Test method business office of representative given on this page(Note : @Test method is marked with pink color in that linked page).

@Test  world void attempt ()    {      driver.findElement(By.xpath("//input[@name='fname']")).sendKeys("alpesh");    WebDriverWait hold off = novel WebDriverWait(driver, 15);    wait.until(ExpectedConditions.elementToBeClickable(By.cssSelector("#submitButton1")));    driver.findElement(By.cssSelector("#submitButton")).click();    wait.until(ExpectedConditions.textToBePresentInElementLocated(By.xpath("//div[@id='timeLeft']"), "Time left: seven seconds"));   }

In higher upward example, When WebDriver clicks on #submitButton page of software spider web application volition live on refreshed in addition to and then WebDriver volition hold off for text = "Time left: seven seconds" on targeted element.
More interesting articles here :Generation Enggelmundus Internet Marketing Tool here :Zeageat IM http://www.software-testing-tutorials-automation.com/

No comments:

Post a Comment