Webdriver FluentWait

Share on Facebook0Share on LinkedIn0Share on Google+0Tweet about this on TwitterEmail this to someoneDigg this

public Wait wait;
WebDriver driver = new FirefoxDriver();
wait = new FluentWait(driver)
.withTimeout(360, TimeUnit.SECONDS)
.pollingEvery(5, TimeUnit.SECONDS)

public WebElement fluentWait(final By locator) {
WebElement foo = wait.until(
new Function() {
public WebElement apply(WebDriver driver) {
return driver.findElement(locator);
return foo;

public WebElement webElement(final By by) {
return wait.until(ExpectedConditions.presenceOfElementLocated(by));

public WebElement webElementVisible(final By by) {
return wait.until(ExpectedConditions.visibilityOfElementLocated(by));

public WebElement clickableElement(final By by) {
return wait.until(ExpectedConditions.elementToBeClickable(by));

Leave a Reply

Your email address will not be published. Required fields are marked *