Selenium waits: stop flaky tests by waiting for a condition
Most flaky Selenium tests fail because the test is faster than the page.
L1–L4 are part of the Pro pass
L0 Explain simply
Analogy: a bus stop. You can stand for exactly ten minutes no matter what. Or you can watch for the bus and give up after twenty. The first plan wastes time, or misses a late bus.
Tom's synthetic Daily List loads tasks asynchronously. A polls for a specific state needed by the next step. A always pauses for its chosen duration. Mixed waits combine session-level implicit waiting with an explicit wait; Selenium warns that this can produce unpredictable waiting times.
Watching for the bus is useful only if you identify the right bus. Likewise, waiting for any button is not the same as waiting for the required task state.
The picture has a limit. A timeout bounds the waiting policy, not necessarily the exact wall-clock duration of every command. Waiting does not repair missing functionality or establish an acceptable .
(SYNTHETIC / TRAINING ONLY: Daily List and every named person are invented.)
PLAIN WORDS · 1 in this section
- selenium
- A free tool that drives a web browser for checks.
PICTURE IT
The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.
THE REAL JOB Synchronize the next operation with a relevant bounded condition and verify the required outcome.
- Condition
- Wait
- Limit
HOW THE PICTURE MAPS
| In the picture | In the software |
|---|---|
| Watching for the bus | Waiting for a condition |
| Standing for ten minutes | A fixed sleep |
| Giving up after twenty minutes | The time limit |
| Two timetables on the wall | Mixed waits |
WHERE THIS PICTURE STOPS
- The condition must match the next need; visible and enabled is not a complete business-success oracle.
- A timeout policy is not an exact wall-clock promise or a product performance requirement.
HOOK
Watch for the bus.
TELL A FRIEND
A bus stop: watch, do not just stand.
OFTEN MIXED UP WITH Selenium locators: find elements in a way that survives change. That topic picks locators that last. This one waits for the page without guessing time.
Sources & standards — 3 sources
- Market practice
Waiting strategies — Selenium ↗ — Selenium project · Asynchronous readiness; implicit waits; explicit waits; warning not to mix waits (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Python expected conditions — Selenium ↗ — Selenium project · element_to_be_clickable: visible and enabled; staleness_of (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Python WebDriverWait implementation — Selenium 4.52.0 — Selenium ↗ — Selenium project · Tagged wait.py: condition evaluation, monotonic deadline check and polling loop (selected actual primary passages read 7 November 2026; Selenium 4.52.0 Python source tag).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
PRACTISE AND KEEP
Sources for this topic — 3 sources
- Market practice
Waiting strategies — Selenium ↗ — Selenium project · Asynchronous readiness; implicit waits; explicit waits; warning not to mix waits (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Python expected conditions — Selenium ↗ — Selenium project · element_to_be_clickable: visible and enabled; staleness_of (selected actual primary passages read 7 November 2026; live Selenium guide/API documentation; no fixed edition claimed).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
- Market practice
Python WebDriverWait implementation — Selenium 4.52.0 — Selenium ↗ — Selenium project · Tagged wait.py: condition evaluation, monotonic deadline check and polling loop (selected actual primary passages read 7 November 2026; Selenium 4.52.0 Python source tag).
Selected primary passages actually read on the access date; not every linked guide. Live documentation and the explicitly tagged wait implementation have distinct version scopes. Daily List rules, people, identifiers and observations are synthetic; educational examples do not claim a vendor-package or live-app run.
Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.