Implicit wait is the simple approach. You set it once, and it applies to every findElement() call. If the element isn't found immediately, Selenium retries for up to the specified time before throwing an exception.
import java.time.Duration;
WebDriver driver = new ChromeDriver();
// Set implicit wait — applies to ALL findElement() calls
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
driver.get("https://www.testerrank.com/banking");
// If this element takes up to 10 seconds to appear,
// Selenium keeps retrying instead of failing immediately
WebElement dashboard = driver.findElement(
By.id("dashboard-header"));
System.out.println("Found: " + dashboard.getText());When findElement() is called: (1) Try to find the element. (2) Found? Return it immediately. (3) Not found? Wait ~500ms, try again. (4) Repeat until found or timeout. (5) If timeout — throw NoSuchElementException.
| Implicit Wait | Explicit Wait |
|---|---|
| Set once — applies to ALL findElement() calls | Used per element with specific conditions |
| Only checks if element EXISTS in the DOM | Can check visibility, clickability, text, URL, title... |
| Cannot wait for visibility, clickability, or text | Precise control over what to wait for |
| Slows down negative tests (waits full timeout to confirm absence) | Doesn't affect other findElement() calls |
| Simpler — one line of code | More code but MUCH more reliable |
In interviews, always mention that implicit wait only checks for PRESENCE in the DOM — not visibility, not clickability. An element can be present but hidden behind a loading overlay. That's why explicit waits are recommended.
Key Point: Implicit wait: set once, applies everywhere, only checks if element exists in DOM. Limited but simple.