Testing / Selenium Interview questions
Explain the internal working of Selenium's explicit wait polling mechanism?
WebDriverWait is built on a lower-level FluentWait, which runs a loop that repeatedly invokes the supplied condition function against the driver, sleeping for a fixed polling interval (500ms by default) between each attempt.
flowchart TD
A[wait.until condition called] --> B[Evaluate condition function]
B --> C{Condition true?}
C -->|Yes| D[Return result immediately]
C -->|No| E{Timeout elapsed?}
E -->|No| F[Sleep polling interval]
F --> B
E -->|Yes| G[Throw TimeoutException]
Each poll re-evaluates the condition from scratch, so a condition like elementToBeClickable genuinely re-runs its underlying findElement and state checks on every single iteration rather than checking once and caching. By default, transient exceptions like NoSuchElementException thrown mid-poll are silently ignored so the loop can keep retrying, but FluentWait.ignoring() controls exactly which exception types get swallowed this way versus immediately propagating and aborting the wait.
More Related questions...