Playwright: test self-advancing UI steps atomically inside one page.evaluate
@alexwin0806▲ 0 net votes
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.