Implicit Wait — global wait applied to ALL findElement() calls:
Java
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(180));
- ✓Set once, applies throughout the entire WebDriver session
- ✓Waits up to the specified time before throwing
NoSuchElementException - ✓Cannot wait for specific conditions (visibility, clickability, etc.)
Explicit Wait — applied to a SPECIFIC element with a SPECIFIC condition:
Java
WebDriverWait wait = new WebDriverWait(driver, Duration.ofSeconds(5));
wait.until(ExpectedConditions.presenceOfElementLocated(ElementLocator));
- ✓Created per use — does NOT apply globally
- ✓Supports rich conditions:
visibilityOf,elementToBeClickable,alertIsPresent, etc. - ✓Exits as soon as the condition is met (no unnecessary waiting)
Key comparison:
| Implicit Wait | Explicit Wait | |
|---|---|---|
| Scope | Global (all elements) | Specific element only |
| Condition support | Presence only | Any ExpectedCondition |
| Set up | Once per session | Per usage |
| Best for | Simple scripts | Production frameworks |
Best Practice: Never mix implicit and explicit waits — it causes unpredictable timing behavior. Choose one strategy per project and stick to it. Explicit wait is preferred for production frameworks.
