API …
Dynamic & timing

Flaky test lab

Twelve classic UI flakes: late buttons, overlays, moving targets, stale nodes, vanishing toasts and more.

Practice tasks

  • Click the late-enabled Submit button with auto-waiting only: no sleep, no waitForTimeout. Prove it with npx playwright test --repeat-each=20.
  • Read Playwright’s call log when the overlay covers Pay now (“<div> intercepts pointer events”) and explain why force: true is the wrong fix.
  • Click the moving button: let actionability (stable) wait for it, then pause the animation and compare the timings in the trace viewer.
  • Assert the vanishing toast with a web-first assertion: await expect(page.getByTestId('fast-toast')).toBeVisible() started right after the click.
  • Pick Banana while the list reshuffles; explain why nth() is the wrong locator and getByTestId('reorder-pick-banana') is the right one.
  • Force each A/B variant with ?variant=a|b|c and assert the matching heading and button pair.
  • Dismiss the cookie banner only when it shows up (page.addLocatorHandler) and keep the checkout flow unchanged.
  • Type “Sam” into the focus-stealing field and make the assertion robust with expect(input).toHaveValue('Sam') plus a retry via expect(...).toPass().
  • Hover Account and click Logout inside the auto-closing menu: decide between clicking the trigger and hover + immediate click.
  • Place exactly one order and assert the count, then break it with dblclick() and fix the app with the guard checkbox.
  • Click the button inside the reloading iframe with page.frameLocator('iframe[name=flaky-frame]') and explain why a cached Frame object fails.

More Dynamic & timing practice