We use cookies to analyze site traffic and show personalized ads. You can accept all cookies or decline personalized advertising.
Learn more in our Privacy Policy.
Set a global timeout for findElement calls to handle basic timing issues
An implicit wait tells Selenium to wait a specified amount of time when trying to find an element if it's not immediately available.
Once set, it applies to all findElement and findElements calls for the lifetime of the WebDriver instance.
Sets a global wait time for findElement calls.
If an element isn't found immediately, Selenium will keep trying until:
NoSuchElementExceptionImagine a page where elements load with a slight delay. This demo shows how implicit wait keeps retrying:
Click the button to start simulation...
Click the button to see how Selenium retries finding an element with implicit wait enabled!
driver.findElement(By.id("btn"))1234567891011121314151617WebDriver driver = new ChromeDriver();
// Set implicit wait to 10 seconds - applies globally
driver.manage().timeouts()
.implicitlyWait(Duration.ofSeconds(10));
// Navigate to the page
driver.get("https://example.com/dynamic-page");
// This will wait up to 10 seconds for the element to appear
WebElement delayedButton = driver.findElement(By.id("delayed-button"));
delayedButton.click();
// All subsequent findElement calls also use the 10s timeout
WebElement anotherElement = driver.findElement(By.className("content"));
driver.quit();findElement calls in this WebDriver session.NoSuchElementException.findElement call also benefits from the 10-second implicit wait. You don't need to set it again.Implicit wait is set once at the start of your test and applies to every findElement call. You don't need to repeat it.
Use short timeouts (3-5 seconds) for implicit waits. Long timeouts slow down failing tests significantly, since Selenium will always wait the full duration before throwing an exception.
For modern, dynamic web apps, prefer explicit waits. They're more precise, readable, and let you specify different conditions (visibility, clickability, text changes).