How to use Implicit wait in Selenium Webdriver
-
Posted by
Mukesh Otwani

15
Jun
This guide will help you to understand implicit wait in Selenium Webdriver and implementation as well. If you have ever worked on any automation tool then you must be aware of Sync issues in the script.
It is one of the biggest pain for an automation engineer to handle sync issues between elements.
Sometimes an application will not able to load elements due to the below issues.
Once you move forward, you will get to know some more Timeout in Selenium like
Page load timeout in Selenium
Script load timeout in Selenium
Implicit wait in selenium Webdriver (Current reading)
Explicit wait in Selenium
Fluent wait in Selenium
Do not confuse with these exceptions because each of this having different usage.
Complete program with usage of implicit wait in selenium webdriver
Note- This is the max time so if any element is coming before 30 seconds it will move to next element.
- Network issue
- Application issues
- Browser stopping JavaScript call.
Syntax of Implicit wait in selenium webdriver
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);Here in above example, I have used TimeUnit as seconds but you have so many options to use Seconds, Minutes, Days, Hours, Microsecond, Milliseconds, and so on check the below screenshot for more information.

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
public class VerifyTitle
{
@Test
public void verifySeleniumTitle()
{
WebDriver driver=new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://vistasadprojects.com/mukeshotwani-blogs-v3");
// Specify implicit wait of 30 seconds
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);
// No login id is present on Webpage so this will fail our script.
driver.findElement(By.id("login")).sendKeys(" Selenium Webdriver");
}
}
Console- The above script will fail because no login id is present on the page but it will wait for max 30 seconds before throwing an exception.

while iam trying to run my java application in eclipse iam getting an error saying that “could not load main class” . can you please help me out with this.
Hi Abhinav,
Are you using @Test annotation from TestNG/JUnint? If not, then you need to use main method to execute your code
what is the polling time for implicit wait. Does it recheck after 10 seconds if 10 seconds is the max time mentioned.
Hi Siddharth,
It is 0.5 second
which one will be considered first, when both Implicit and Explicit waits are in picture.
Some scenarios –
when Implicit time out is 20 sec and explicit Time out is 30 sec
What will happen if the element is found out
1. at 10th sec
2. at 25th sec
3. at 31st sec
4. at 50th sec
Hi Venkatesh,
First of all Implicit wait will be applied for all elements and Explicit wait works for specific conditions.
Now let’s talk about condition if element found within 20 sec then it will continue with execution else it will throw noSuchElementException.
Thanks
Mukesh Otwani
Hi,
is this wait time applicable for the entire script once it is mentioned.
Like will it wait for the element visibility for each and every element in the script?
Hi Pooja,
Implicit wait works throughout the script once. But for element visibility, you have to use Explicit wait.
what happens if element came after 30 seconds it will throw exceptions
Hi Dinesh,
It will throw an exception
Is Implicit wait applicable only for elements which are identified using findElement() method of webdriver instance?
Hi Ekta,
Yes, Implicit Wait tell WebDriver to poll DOM while finding an element for given time.
Brilliant explanation on Implicit Wait. Thanks Mukesh !!!
Thanks Debanjan 🙂 Keep visiting.
I want to execute the code slowly to observe each step, how can i use wait for it
Hi Raja,
Set toggle breakpoints inside your script and debug it. This way, you can execute step by step.
Hi Mukesh,
Very nice blog i ove it. i have one question.
Explicity wait will use for all the times like thread.sleep();?
Hi Pooja,
As the name of wait i.e. Explicit itself explaining its exclusive and specific usage. And no doubt Explicit waits are better than Thread.sleep().
Thanks. It’s helpful and easy to implement and best part was the timeout screenshot that you shared which highlight it weighted for 30 seconds. NewBies generally miss such details. Keep up the good work
Thanks Gaurav
in tutorial u said that default time is 250 ms.if i mention 30 s. driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS); how can this work.what is the total wait…plz explain?
Hi,
In above scenario if element not found then max time wait will be 30 seconds and if element comes before 30 seconds it will continue to next steps.
what default timeout for implicit wait..
Default timeout is ZERO. Default polling time is 250 millisecond if implicit wait given.
what is the polling time for explicit wait?
Hi Venkatesh,
Default polling for Explicit Wait in 500 milliseconds…