显式等待 Explicit wait
Function<WebDriver, Boolean> waitFn = new Function<WebDriver, Boolean>() {
@Override
public Boolean apply(WebDriver driver) {
Point newPos = page.getWDGAttrDetail().getLocation();
return newPos.getY() != prePos.getY();
}
};
SeleniumUtil.createWait(page.getDriver()).until(waitFn);
WebElement myDynamicElement = (new WebDriverWait(driver, 10)) .until(ExpectedConditions.presenceOfElementLocated(locator))
new WebDriverWait(driver, 10). until(ExpectedConditions.elementToBeClickable(locator));
new WebDriverWait(driver, 10). until(ExpectedConditions.visibilityOf(locator));
//wait for processing icon present
Function<WebDriver, WebElement> waitFn = new Function<WebDriver, WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
return el.findElement(By.cssSelector("div.rptstatus.rptcomplete"));
}
};
WebDriverWait wait = new WebDriverWait(driver, 120, 2);
wait.withMessage("A processing icon should appear in the Status column of the row '"+templateName+"'.");
wait.until(waitFn);
隐式等待 Implicit wait
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS)

