Implicit wait and Explicit wait
public static void wait01(WebDriver driver) {
WebElement element = driver.findElement(By.name(""));
// implicit wait
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
// explicit wait
WebDriverWait explicitwait = new WebDriverWait(driver, 10);
explicitwait.until(ExpectedConditions.elementToBeClickable(element));
}
Fluent Wait
public static void wait02(WebDriver driver) {
// fluent wait
org.openqa.selenium.support.ui.Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
.withTimeout(10, TimeUnit.SECONDS)
.pollingEvery(3, TimeUnit.SECONDS);
wait.until(new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
// TODO Auto-generated method stub
return driver.findElement(By.name(""));
}
});
}
No comments:
Post a Comment