Selenium Wait Implicit Wait Explicit Wait Fluent Wait

Selenium Wait  Command is used in Selenium WebDriver to wait a particular amount of time defined by user.Selenium Wait can be divided into two categories Implicit wait and Explicit wait and another type of hybrid wait is Fluent Wait.In the implicit wait selenium WebDriver wait for a fixed amount of time before executing next command or throwing an exception . Where in all other Selenium Wait type of  WebDriver will execute the next line of command if it found that element.

Implicit wait

This is the Selenium Wait statement gives command to the browser to wait for an certain period of time in that time if the element is located in the page the execution will take place or else the “WebDriver wait” for a specific amount of time to check whether the element is located on that page or not.

driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);

[codesyntax lang=”java”]

package tesng;
public class robot { protected WebDriver driver;
 @Test public void tutorials() throws InterruptedException { 
System.setProperty("webdriver.gecko.driver", "D:\\geckodriver.exe");
 driver = new FirefoxDriver(); driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS); 
driver.get(""); System.out.println(driver.findElement(By.linkText("The Moneyologist")).getTagName()); } }


In above example  the WebDriver wait for 10 Second to find the link text is present or not.

Note for implicit-From Selenium 3.0.1 release the WebDriver is not throwing the exception “Element not Found Exception” instead of  it is waiting for element to be present.

Explicit wait

An explicit wait is a wait statement let the user to define for a certain condition and predefined time to wait for  proceeding further in the code. The Explicit wait wait for an particular event to occur in that period of time to perform any operation on that  web element.

Pages: 1 2