3
我想知道如何用lambda替換流行的WebDriverWait
。如何用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表達式代替它呢?
如果你在IDE中這樣做,每個像樣的現代IDE都有一個快速修復或重構,如「將匿名類轉換爲lambda表達式」。只要點擊它,你就會好起來的。 –