SoftwareTestPilot

Why fixed sleeps break and auto-waiting helps. Simulated in your browser, free, no sign-in.

Waits & Flaky Tests

Step 1 of 5

Now simulating · step 1 of 5

The checkout page

Paused

Educational model of Playwright click actionability on a virtual clock. All timing is simulated; nothing waits in real time.

Slow but successful

Checkout

2 items - total 42.00

Page at 0.0 s (simulated)

0s1s2s3s4s5s6s

Green = check passing. Grey = fixed sleep; red shading = sleep after the button was already ready. Circle = click, diamond = assertion. All timing simulated.

Tip: click a coloured area or an edge line to see what it does.

Text description of this step
  • Scenario: Slow but successful. Simulated times.
  • Visible passes at 1200 ms.
  • Stable passes at 1500 ms.
  • Receives events passes at 2000 ms.
  • Enabled passes at 2600 ms.
Speed

Keyboard: Space plays or pauses (when not typing).

Learning objective: Explain what a click checks before it acts, why fixed sleeps waste time and still fail, and use a retrying assertion for the outcome.

Step 1 · Beginner

The checkout page

The Place order button appears, stops moving, waits for a loading overlay to clear, and becomes enabled. After a click, the order confirmation shows a bit later.

Expected outcome: Watch each condition on the timeline.

A fixed sleep does not switch off Playwright's waiting: the click after it still runs every check below with its own timeout. The sleep only moves the start later.

  • Visible: Element is attached and has a non-empty box without visibility:hidden.
  • Stable: Same bounding box for two consecutive animation frames (movement stopped).
  • Receives events: Element is the hit target at the click point, not covered by an overlay.
  • Enabled: Not disabled (for example a <button disabled>).
Not modelled here
  • Scrolling the element into view
  • Exact retry intervals between checks
  • The editable check (used by fill, not click)
  • force: true and trial runs
  • Hit-target details such as partial overlap
  • Waiting for navigation after the click

Source: Playwright actionability checks.

Clickable is not the same as correct. Assert the business result (order confirmed with the right total) with a retrying assertion.

About this lesson

You will learn to

  • Explain what Playwright checks before a click.
  • Show why a fixed sleep wastes time and still leaves risk.
  • Use a retrying assertion for the business outcome and read timelines to explain flaky runs.

Before you start

  • Know what a Playwright click and expect() look like.

Your progress on this topic

Explored
0 of 5 guided steps viewed
Practiced
  • Not yet: Run a test in the timing lab
  • Not yet: Make a run fail and read its timeline
Challenges passed
  • Beginner: 0 of 3 · hints 0 · wrong answers 0
  • Practitioner: 0 of 3 · hints 0 · wrong answers 0
  • Advanced: 0 of 2 · hints 0 · wrong answers 0

Watching the walkthrough only counts as explored. Practice needs you to use the lab yourself, and a challenge passes only when your answer meets its criteria.

Practise more

Intentional failure: Result arrives after the assertion timeout

Nothing is posted anywhere. You choose where to paste the link or summary.

How to explain this in an interview

"A Playwright click already waits until the element is visible, stable, enabled and receiving events, so a fixed sleep only delays it and still fails on slower runs. A successful click proves the button was usable, not that the order exists, so I follow it with a retrying assertion such as toHaveText on the result. When a test is flaky I look for the source of the variation before touching timeouts."

Next recommended topicDefect Life Cycle

Progress is saved on this browser only. It is not linked to your account and other devices will not see it.