我想知道如何用lambda代替流行的WebDriverWait
用于显式地等待某个事件。
代码片段:
(new WebDriverWait(Driver.driver.get(), 10)).until(new ExpectedCondition<Boolean>() {
public Boolean apply(WebDriver d) {
return d.findElement(By.id("DataTables_Table_0_processing")).isDisplayed();
}
});
或:
(new WebDriverWait(Driver.driver.get(), 10))
.until(ExpectedConditions
.invisibilityOfElementLocated(By.id("DataTables_Table_0_processing")));
如何用lambda表达式替换它?
(new WebDriverWait(Driver.driver.get(), 10))
.until(d -> d.findElement(By.id("DataTables_Table_0_processing")).isDisplayed());
我不认为第二种情况可以用lambda来改善,因为已经有一个方便的方法提供了足够的清晰度。