I am struggling to figure out how the WebDriver instance is passed to Selenium's expected conditions.
So I have a simple WebDriverWait for the visibility of a web element:
new WebDriverWait(webDriver, Configuration.WEB_DRIVER_WAIT_TIMEOUT)
.until(ExpectedConditions.visibilityOf(element));
The webDriver instance here is a chromedriver which has been instantiated above.
My question is: in the method visibilityOf():
public static ExpectedCondition<WebElement> visibilityOf(final WebElement element) {
return new ExpectedCondition<WebElement>() {
@Override
public WebElement apply(WebDriver driver) {
return elementIfVisible(element);
}
@Override
public String toString() {
return "visibility of " + element;
}
};
}
Just above, how and which instance of WebDriver gets passed to the apply()? I understand that the ExpectedCondition implements the Function Interface
public interface ExpectedCondition<T> extends Function<WebDriver, T> {}
which takes as first argument WebDriver.
How the instance of the WebDriver gets passed to ExpectedCondition of the visibilytOf()?
Thanks