Skip to main content

Explicit Wait

An explicit wait pauses test execution until a specific condition is met — an element becomes visible, clickable, or a certain value appears — up to a defined timeout, rather than waiting a fixed amount of time regardless of whether it's needed. It's the standard fix for most timing-related flaky tests.

A hard-coded `sleep(5)` either wastes time when the condition is met sooner, or still fails intermittently when the page happens to take longer than five seconds — the worst of both. An explicit wait for "element is clickable, timeout 10 seconds" resolves as soon as the condition is true, and only fails if it genuinely never becomes true within the allotted time.

Selenium requires explicit waits to be written deliberately in test code; Playwright and Cypress build equivalent waiting behavior into nearly every action automatically, which is a large part of why tests written in those frameworks tend to be less flaky out of the box.

Explicit Wait — Definition, Example & How It's Used | QA Bash Glossary | QA Bash