protected final boolean waitForPageNotBusy(By by = By.className("busyOverlay")) {
log.debug("Waiting for page not busy...")
def timeout = 120
boolean isNotBusy = new FluentWait(driver)
.withMessage("Busy overlay still visible after $timeout seconds.")
.pollingEvery(1, TimeUnit.SECONDS)
.withTimeout(timeout, TimeUnit.SECONDS)
.ignoring(org.openqa.selenium.NoSuchElementException.class)
.ignoring(UnhandledAlertException.class)
.until(ExpectedConditions.invisibilityOfElementLocated(by) as Function);
isNotBusy
}
通过Saifur建议的循环:
protected final boolean waitForPageNotBusy() {
By by = By.className("busyOverlay")
log.debug("Waiting for element to disappear: {}", by.toString())
try {
while (driver.findElements(by).size() > 0) {
log.debug("Element still visible: {}", by.toString())
sleep(1000)
}
} catch (NoSuchElementException nse) {
log.debug(nse.message)
return true
}
}
1 回答
取代流利的等待:
通过Saifur建议的循环:
可以解决我的问题 .