How to fix Playwright "Execution context was destroyed" errors?
PlaywrightThis happens when the page navigates or reloads while your script is still evaluating in the old document.
Wait for navigation intentionally and then re-query locators.
await Promise.all([
page.waitForURL('**/dashboard'),
page.getByRole('button', { name: 'Sign in' }).click(),
]);
await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible();
Do not keep stale ElementHandle references across navigations.