Software Testing

Selenium Implicit Wait

Selenium Implicit Wait

An implicit wait tells the 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 when we define the implicit wait, it will set for the life of the WebDriver object instance.

It is a mechanism which will be written once and applied for entire session automatically. It should be applied immediately once we initiate the Webdriver.

Implicit wait will not work all the commands/statements in the application. It will work only for “FindElement” and “FindElements” statements.

If we set implicit wait, find element will not throw an exception if the element is not found in first instance, instead it will poll for the element until the timeout and then proceeds further. We should always remember to add the below syntax immediately below the Webdriver statement.

Implicit Wait Syntax

The general syntax is as follows:

driver.manage.TimeOuts.implicitwait(6,Timeunit.SECONDS);

Example using implicit timeout

WebDriver driver = new FirefoxDriver();
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
driver.get("https://www.google.com");

Selenium Tutorials

Selenium Tutorials on this website: