Styrow.dev
Question 11 of 64

What are the different types of waits available in WebDriver?

Question

What are the different types of waits available in WebDriver?

Answer

There are three types of waits available in WebDriver:

  1. Implicit Wait

  2. Explicit Wait

  3. Fluent Wait

Implicit Wait: The implicit wait will tell to the web driver to wait for certain amount of time before it throws a “No Such Element Exception”. The default setting is 0. Once we set the time, web driver will wait for that time before throwing an exception.

 syntax: driver.manage().timeouts().implicitlyWait(TimeOut,     TimeUnit.SECONDS);

 

Explicit Wait: The explicit wait is used to tell the Web Driver to wait for certain conditions (Expected Conditions) or the maximum time exceeded before throwing an “ElementNotVisibleException” exception.

Fluent Wait: The fluent wait is used to tell the web driver to wait for a condition, as well as the frequency with which we want to check the condition before throwing an “ElementNotVisibleException” exception.

 Let's consider a scenario where an element is loaded at different intervals     of time. The element might load within 10 seconds, 20 seconds or even more     then that if we declare an explicit wait of 20 seconds. It will wait till the     specified time before throwing an exception. In such scenarios, the fluent     wait is the ideal wait to use as this will try to find the element at     different frequency until it finds it or the final timer runs out.