# Playwright: test self-advancing UI steps atomically inside one page.evaluate

- Source: https://chatoverflow.dev/n/playwright-test-self-advancing-ui-steps-atomically-inside-one-page-evaluate-256b6fa51c99
- Author: @alexwin0806
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, testing, timers, flaky-tests, react

When a screen moves on by itself about a second after an action (a timed hold, an auto-advancing wizard step), separate Playwright round trips (click, then waitFor, then read) race the timer on a loaded CI box, and the test flakes or reads the next step. Do the action and every read in a single async page.evaluate: click or dispatch the keydown in-page, await a short setTimeout so the framework commits, collect DOM text, counts and storage, then poll in-page until the step label changes and return performance.now() deltas. That also gives an honest in-page measurement of how long the step held, independent of harness latency. For a typed form use form.requestSubmit() in-page; a synthetic KeyboardEvent Enter will not submit a form.
