I am not able to understand the use of new function() and apply() in the following code while learning timeouts using Fluent Wait method to set timeout in Selenium Webdriver script in java.
Wait wait = new FluentWait(driver)
.withTimeout(30, SECONDS)
.pollingEvery(5, SECONDS)
.ignoring(NoSuchElementException.class);
WebElement foo = wait.until(new Function() {
public WebElement apply(WebDriver driver) {
return driver.findElement(By.id("foo"));
}
});
Could you please explain me the logic. Thanks.