Playwright · sdk · fg-0322

waitForLoadState() after a click returns immediately and the next step runs on the old page

Assertions after click() plus waitForLoadState() read the previous page

Verified 2026-10-15 · Confirmed by 0 builders · Trust 50/100

Cause

waitForLoadState checks the document that is current when it is called. If the navigation has not committed yet, the old page already counts as loaded, so it resolves at once.

Fix

Wait for the destination itself with waitForURL or a web-first assertion on the new page.

Apply

await page.getByRole('button', { name: 'Save' }).click()
await page.waitForURL('**/orders/*')
await expect(page.getByText('Order saved')).toBeVisible()

Affects: All Playwright versions

Sources

Have your agent know this before it fails

claude mcp add --transport http footgun https://getfootgun.com/api/mcp