How is the FluentWait is different from WebDriverWait? I am using WebDriverWait having the polling interval set to : 500 miliseconds. Still, WebDriverWait returns after some delay (i.e. 2 - 3 seconds after the element load is completed)? Any opinion here?

  • Hope this will help you : toolsqa.com/selenium-webdriver/implicit-explicit-n-fluent-wait Apr 30 '15 at 8:33
  • Hi,Thanks much for the very helpful link. But, I didn't understand WebDriverWait is an implicit wait or explicit wait .
    – Dinesh
    Apr 30 '15 at 11:43
  • If you read the documentation, you will see that both implicit and explicit are functionally equivalent. Both of them poll the DOM every 500 ms. Apr 30 '15 at 11:51
  • Yeah got it ... But, I am still confused on : WebDriverWait or FluentWait ... any suggestions? Most of the time, I will have to wait for the element to be visible
    – Dinesh
    Apr 30 '15 at 11:55
  • As per this question, WebDriverWait is and extension of FluentWait. Apr 30 '15 at 12:46

Implicit Wait: An implicit wait is to tell WebDriver to poll the DOM for a certain amount of time when trying to find an element or elements if they are not immediately available. The default setting is 0. Once set, the implicit wait is set for the life of the WebDriver object instance.

WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
WebElement myDynamicElement = driver.findElement(By.id("myDynamicElement"));

When to use: Not recommended

Explicit wait: An explicit waits is code you define to wait for a certain condition to occur before proceeding further in the code. WebDriverWait by default calls the ExpectedCondition every 500 milliseconds until it returns successfully.

WebDriver driver = new FirefoxDriver();
WebElement myDynamicElement = (new WebDriverWait(driver, 10))

When to use: If element takes a long time to load. Also, used to check property of an element (presence, clickability. etc).

FluentWait: For each FluentWait instance, you can specify:

  1. Frequency with which FluentWait has to check the conditions defined.
  2. Ignore specific types of exception waiting such as NoSuchElementExceptions while searching for an element on the page.
  3. Maximum amount of time to wait for a condition

When to use FluentWait: When you try to test the presence of an element that may appear after every x seconds/minutes (Just an example, this is my guess of where such a thing can be used).

// Waiting 30 seconds for an element to be present on the page, checking
// for its presence once every 5 seconds.
Wait<WebDriver> wait = new FluentWait<WebDriver>(driver)
    .withTimeout(30, SECONDS)
    .pollingEvery(5, SECONDS)

WebElement foo = wait.until(new Function<WebDriver, WebElement>() 
  public WebElement apply(WebDriver driver) {
  return driver.findElement(By.id("foo"));
  • Thanks much for the detailed answer. Let me try out in my code to see the change in response time. I am having the following issue in my code : I am using webDriverWait for the loader to complete (ex : in a page, the set of data loads on clicking the checkbox and there is a loading icon appears to indicate user that, the loading is still in progress. I am using webDriverWait to identify if the loading icon is disappeared. The code is working fine, but the webDriverWait returns after few seconds of delay (2-3 seconds)webDriverWait returns with a lag of 2-3 seconds of loading icon disappeared.
    – Dinesh
    May 5 '15 at 6:04
  • @LittlePanda. Your code for FluentWait is not valid Syntax. May 8 '18 at 15:02

Implicit wait: Implicit wait tells web driver to wait on every instance when try to find element. It is like global wait for all driver.findelement instance. It will force web driver to wait until element is appeared on page or defined time whatever is earliest. Drawback is it throws exception when element is not loaded on page even in defined time span.

Explicit wait: Explicit wait is of two types:

1) WebDriverWait

2) FluentWait

both are classes and implements Wait interface.

WebDriverWait is applied on certain element with defined expected condition and time. This wait is only applied to the specified element. This wait can also throw exception when element is not found.

WebDriverWait wait = new WebDriverWait (driver, 20);
wait.until(ExpectedConditions.VisibilityofElementLocated(By.xpath(""//button[@value='Save Changes']"")));

Fluent wait: Fluent wait is another type of Explicit wait and you can define polling and ignore the exception to continue with script execution in case element is not found.

new FluentWait<WebDriver>(driver).withTimeout(30, TimeUnit.SECONDS).pollingevery(10, TimeUnit.SECONDS).ignoring(NoSuchElementException.class);

Implicit Wait is attached to the WebDriver instance. It will get invoked before performing any operation using driver instance.

Explicit Wait is Highly customizable. You can achieve Explicit Wait using Two classes:

  1. FluentWait (Class)
  2. WebDriverWait (Class)

FluentWait class has below methods to configure the wait.

  1. withTimeOut()
  2. pollingEvery()
  3. ignoring()
  4. until()

WebDriverWait class is an extension of FluentWait class. It doesn't have its own methods.

But it has certain constructors which will help you to configure your wait instance without invoking the methods.

WebDriverWait takes WebDriver instance as an argument, unlike FluentWait. For More Details watch this: https://youtu.be/FbGOhbzCoyk

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.