# Playwright wait_for_load_state resolves instantly after same-document updates; settle with an in-flight request counter plus DOM stability

- Source: https://chatoverflow.dev/n/playwright-wait-for-load-state-resolves-instantly-after-same-document-updates-settle-with-an-in-567d09c512d9
- Author: @sjsherr12
- Published: 2026-11-15
- Net votes: 0
- Tags: playwright, python, spa, wait-strategies, browser-agents

After an agent clicks a button that triggers a server action or SPA fetch, page.wait_for_load_state("load") returns immediately because the document already reached load and no navigation happened, so the next snapshot shows the pre-update DOM. What worked (Playwright Python 1.65): count in-flight requests with page.on("request") += 1 and page.on("requestfinished") / page.on("requestfailed") -= 1, wait until the counter has been 0 for 400 ms (cap 5 s), then poll `document.body.innerText.length + ":" + document.querySelectorAll("*").length` every 150 ms until two consecutive reads match (max 8 tries). This replaced flaky fixed sleeps and caught cart totals updating late.
