-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
Description
Version
1.49.0
Steps to reproduce
Reported by @chrisbottin in #32899 (comment).
The problem we are having is when we click on a link which triggers the beforeunload dialog, after we dismiss the dialog and try to interact with the page again, we get timeout errors.
Here is a simple test replicating the error ...
const {chromium} = require('playwright');
const {expect} = require('@playwright/test');
(async () => {
const browser = await chromium.launch();
const page = await browser.newPage();
await page.mainFrame().goto('https://www.npmjs.com/');
expect(await page.mainFrame().title()).toStrictEqual('npm | Home');
await page.evaluate(() => {
window.onbeforeunload = () => false;
});
page.on('dialog', async dialog => {
await dialog.dismiss();
});
await page.getByRole('menuitem', {name: 'Teams'}).click({noWaitAfter: true});
await page.evaluate(() => {
window.onbeforeunload = null;
});
// Timeout error will occur here:
await page.getByRole('menuitem', {name: 'Teams'}).click({timeout: 1000});
expect(await page.mainFrame().title()).toStrictEqual('npm | Teams');
await browser.close();
})();Expected behavior
Test passes.
Actual behavior
The test fails on the line await page.getByRole('menuitem', {name: 'Teams'}).click({timeout: 1000}); with the error:
locator.click: Timeout 1000ms exceeded.
Call log:
- waiting for getByRole('menuitem', { name: 'Teams' })
- waiting for navigation to finish...
Additional context
During debugging, I noticed the pendingDocument() is set to {documentId: undefined, request: undefined}
If this line
| if (!mainFrame || !mainFrame.pendingDocument()) |
if (!mainFrame || !mainFrame.pendingDocument() || !mainFrame.pendingDocument().documentId)
return;Environment
unknownReactions are currently unavailable