Click on the button below. The paragraph field will tell you when 1, 2, 3, 4, 5, 6, 7, 8, 9 and 10 seconds have passed.
0
package com.wait.type; import java.util.NoSuchElementException; import java.util.concurrent.TimeUnit; import org.openqa.selenium.By; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.Assert; import org.testng.Reporter; import org.testng.annotations.Test; public class ExplicitWaitDemo { @Test public void explicitWait() throws InterruptedException { WebDriver driver; driver = new ChromeDriver(); driver.get("http://anish-selenium.blogspot.in/p/explicit-wait-script.html"); //Using Static Wait that Thread.sleep(3000); It will exactly wait for 3 Seconds Thread.sleep(3000); driver.findElement(By.xpath("//button[text()='Display Time in Seconds']")).click(); WebDriverWait wait = new WebDriverWait(driver, 8); wait.withTimeout(15, TimeUnit.SECONDS); wait.pollingEvery(250, TimeUnit.MILLISECONDS); wait.ignoring(NoSuchElementException.class); wait.until(ExpectedConditions. textToBePresentInElement(driver.findElement(By.id("txt")), "10")); String value = driver.findElement(By.xpath("//*[text()='10']")).getText(); Assert.assertEquals(value, "10"); Reporter.log("Test is Pass"); driver.close(); } }
Hello Anish,
ReplyDeleteThe Article on Selenium Explicit Wait is nice. It give detail information about it .Thanks for Sharing the information on Selenium Explicit Wait is Awesome. mobile application testing
Really Happy to say your post is very interesting. Keep sharing your information regularly for my future reference. Thanks Again.
ReplyDeleteTop Big Data Companies
Top Data Analytics Companies
Top text analytics Companies
Top Software testing companies
Top Machine Learning Companies
Top Mobile App Development Companies