I want to implement a simple waitForXX under webdriver.
The code is pretty simple.
Function<WebDriver, WebElement> presenceOfElementLocated(final By locator) {
return new Function<WebDriver, WebElement>() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
}
};
}
But still it gives me troubles because I can’t seem to import the ‘Function’ part.
I looked every where under selenium.support.ui where it is supposed to be I guess? But I can’t seem to locate it.
I tried with the latest Selenium standalone jar file 2.5.0.
Thanks!
Unfortunately I don’t know how to do that in Java but have you had a look at the WebDriverWait class in WebDriver which should do what you want.
The class is in the Support part of the Java Bindings
http://code.google.com/p/selenium/source/browse/trunk/java/client/src/org/openqa/selenium/support/ui/WebDriverWait.java
See how to use it with these tests
http://code.google.com/p/selenium/source/browse/trunk/java/client/test/org/openqa/selenium/support/ui/WebDriverWaitTest.java
Or you could use implicit waits