Skip to main content
SeleniumDecoded

Implicit Waits

Understand implicit waits, their global behavior, and when to use them versus explicit waits.

Selenium 3 & 4 Medium

Implicit waits tell WebDriver to poll the DOM for a certain amount of time when trying to find elements that are not immediately available. Once set, the implicit wait applies globally to all findElement calls.

Setting Implicit Wait

Configure Implicit Wait
Selenium 3 & 4 Stable
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import java.time.Duration;
WebDriver driver = new ChromeDriver();
// Set implicit wait to 10 seconds
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
// Now all findElement calls will wait up to 10 seconds
WebElement element = driver.findElement(By.id("dynamic-element"));
// If not found within 10 seconds, throws NoSuchElementException
from selenium import webdriver
from selenium.webdriver.common.by import By
driver = webdriver.Chrome()
# Set implicit wait to 10 seconds
driver.implicitly_wait(10)
# Now all find_element calls will wait up to 10 seconds
element = driver.find_element(By.ID, "dynamic-element")
# If not found within 10 seconds, raises NoSuchElementException
const { Builder, By } = require('selenium-webdriver');
const driver = await new Builder().forBrowser('chrome').build();
// Set implicit wait to 10 seconds
await driver.manage().setTimeouts({ implicit: 10000 });
// Now all findElement calls will wait up to 10 seconds
const element = await driver.findElement(By.id('dynamic-element'));
// If not found within 10 seconds, throws NoSuchElementError
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
IWebDriver driver = new ChromeDriver();
// Set implicit wait to 10 seconds
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
// Now all FindElement calls will wait up to 10 seconds
IWebElement element = driver.FindElement(By.Id("dynamic-element"));
// If not found within 10 seconds, throws NoSuchElementException

How Implicit Wait Works

  1. You call findElement()
  2. WebDriver checks if element exists immediately
  3. If not found, WebDriver waits and retries
  4. This continues until element is found OR timeout expires
  5. If timeout expires without finding element, exception is thrown
findElement() called
├─► Element found immediately? ─► YES ─► Return element
NO (element not in DOM)
├─► Wait ~500ms, retry
├─► Element found? ─► YES ─► Return element
NO
├─► Timeout expired? ─► YES ─► Throw NoSuchElementException
NO
└─► Loop back to wait and retry

Implicit Wait Scope

Implicit Wait Is Global
Selenium 3 & 4 Stable
// Set once at the beginning
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
// Applies to ALL subsequent findElement calls
driver.findElement(By.id("header")); // Waits up to 10s
driver.findElement(By.id("content")); // Waits up to 10s
driver.findElement(By.id("footer")); // Waits up to 10s
// Change it anytime
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
// Now all calls wait up to 5 seconds
driver.findElement(By.id("sidebar")); // Waits up to 5s
// Disable implicit wait
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
# Set once at the beginning
driver.implicitly_wait(10)
# Applies to ALL subsequent find_element calls
driver.find_element(By.ID, "header") # Waits up to 10s
driver.find_element(By.ID, "content") # Waits up to 10s
driver.find_element(By.ID, "footer") # Waits up to 10s
# Change it anytime
driver.implicitly_wait(5)
# Now all calls wait up to 5 seconds
driver.find_element(By.ID, "sidebar") # Waits up to 5s
# Disable implicit wait
driver.implicitly_wait(0)
// Set once at the beginning
await driver.manage().setTimeouts({ implicit: 10000 });
// Applies to ALL subsequent findElement calls
await driver.findElement(By.id('header')); // Waits up to 10s
await driver.findElement(By.id('content')); // Waits up to 10s
await driver.findElement(By.id('footer')); // Waits up to 10s
// Change it anytime
await driver.manage().setTimeouts({ implicit: 5000 });
// Now all calls wait up to 5 seconds
await driver.findElement(By.id('sidebar')); // Waits up to 5s
// Disable implicit wait
await driver.manage().setTimeouts({ implicit: 0 });
// Set once at the beginning
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
// Applies to ALL subsequent FindElement calls
driver.FindElement(By.Id("header")); // Waits up to 10s
driver.FindElement(By.Id("content")); // Waits up to 10s
driver.FindElement(By.Id("footer")); // Waits up to 10s
// Change it anytime
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
// Now all calls wait up to 5 seconds
driver.FindElement(By.Id("sidebar")); // Waits up to 5s
// Disable implicit wait
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(0);

Limitations of Implicit Waits

1. Only Waits for Element Existence

Implicit wait only checks if an element exists in the DOM. It does NOT wait for:

  • Element to be visible
  • Element to be clickable
  • Element to have specific text
  • Element to be enabled
  • Any other condition
Implicit Wait Limitations
Selenium 3 & 4 Fragile
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
// Element exists but is hidden - implicit wait returns it anyway!
WebElement hiddenElement = driver.findElement(By.id("loading-spinner"));
hiddenElement.click(); // Might fail - element exists but not clickable
// Element exists but disabled
WebElement disabledButton = driver.findElement(By.id("submit-btn"));
disabledButton.click(); // Might fail - element exists but disabled
// For these cases, use explicit waits instead!
driver.implicitly_wait(10)
# Element exists but is hidden - implicit wait returns it anyway!
hidden_element = driver.find_element(By.ID, "loading-spinner")
hidden_element.click() # Might fail - element exists but not clickable
# Element exists but disabled
disabled_button = driver.find_element(By.ID, "submit-btn")
disabled_button.click() # Might fail - element exists but disabled
# For these cases, use explicit waits instead!
await driver.manage().setTimeouts({ implicit: 10000 });
// Element exists but is hidden - implicit wait returns it anyway!
const hiddenElement = await driver.findElement(By.id('loading-spinner'));
await hiddenElement.click(); // Might fail - element exists but not clickable
// Element exists but disabled
const disabledButton = await driver.findElement(By.id('submit-btn'));
await disabledButton.click(); // Might fail - element exists but disabled
// For these cases, use explicit waits instead!
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(10);
// Element exists but is hidden - implicit wait returns it anyway!
IWebElement hiddenElement = driver.FindElement(By.Id("loading-spinner"));
hiddenElement.Click(); // Might fail - element exists but not clickable
// Element exists but disabled
IWebElement disabledButton = driver.FindElement(By.Id("submit-btn"));
disabledButton.Click(); // Might fail - element exists but disabled
// For these cases, use explicit waits instead!

2. Slows Down Failing Tests

If an element truly doesn’t exist, you wait the full timeout before failing:

Slow Failure with Implicit Wait
Selenium 3 & 4 Stable
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(30));
// If you're checking for element absence, this is slow!
try {
driver.findElement(By.id("error-message"));
System.out.println("Error is displayed");
} catch (NoSuchElementException e) {
// Takes 30 seconds to reach this point!
System.out.println("No error");
}
// Better: Use findElements which returns empty list immediately
// (but still waits with implicit wait set)
driver.implicitly_wait(30)
# If you're checking for element absence, this is slow!
try:
driver.find_element(By.ID, "error-message")
print("Error is displayed")
except NoSuchElementException:
# Takes 30 seconds to reach this point!
print("No error")
# Better: Use find_elements which returns empty list
# (but still waits with implicit wait set)
await driver.manage().setTimeouts({ implicit: 30000 });
// If you're checking for element absence, this is slow!
try {
await driver.findElement(By.id('error-message'));
console.log('Error is displayed');
} catch (e) {
// Takes 30 seconds to reach this point!
console.log('No error');
}
driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(30);
// If you're checking for element absence, this is slow!
try
{
driver.FindElement(By.Id("error-message"));
Console.WriteLine("Error is displayed");
}
catch (NoSuchElementException)
{
// Takes 30 seconds to reach this point!
Console.WriteLine("No error");
}

Implicit vs Explicit Waits

FeatureImplicit WaitExplicit Wait
ScopeGlobalPer call
ConditionsOnly element existenceAny condition
FlexibilityLowHigh
MixingNot recommendedPreferred
PerformanceCan slow testsMore efficient

Best Practices

  1. Keep implicit waits short (0-5 seconds) or don’t use them
  2. Prefer explicit waits for specific conditions
  3. Don’t mix long implicit waits with explicit waits
  4. Set once at the beginning of your test setup
  5. Consider disabling implicit waits entirely and using only explicit waits
Recommended Approach
Selenium 3 & 4 Stable
public class BaseTest {
protected WebDriver driver;
@BeforeMethod
public void setup() {
driver = new ChromeDriver();
// Option 1: Short implicit wait for basic stability
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(2));
// Option 2: No implicit wait, use explicit waits everywhere
// driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(0));
}
}
class BaseTest:
def setup_method(self):
self.driver = webdriver.Chrome()
# Option 1: Short implicit wait for basic stability
self.driver.implicitly_wait(2)
# Option 2: No implicit wait, use explicit waits everywhere
# self.driver.implicitly_wait(0)
async function setup() {
const driver = await new Builder().forBrowser('chrome').build();
// Option 1: Short implicit wait for basic stability
await driver.manage().setTimeouts({ implicit: 2000 });
// Option 2: No implicit wait, use explicit waits everywhere
// await driver.manage().setTimeouts({ implicit: 0 });
return driver;
}
public class BaseTest
{
protected IWebDriver Driver;
[SetUp]
public void Setup()
{
Driver = new ChromeDriver();
// Option 1: Short implicit wait for basic stability
Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(2);
// Option 2: No implicit wait, use explicit waits everywhere
// Driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(0);
}
}

Next Steps