Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: After dismissing beforeunload dialog, timeout occurs when interacting with the page #33803

Closed
chrisbottin opened this issue Nov 28, 2024 · 1 comment

Comments

@chrisbottin
Copy link

Version

1.49.0

Steps to reproduce

Run the followin code:

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

The test should pass.

Actual behavior

The test fails with a timeout error on the line await page.getByRole('menuitem', {name: 'Teams'}).click({timeout: 1000});

Timeout error:

locator.click: Timeout 1000ms exceeded.
Call log:
  - waiting for getByRole('menuitem', { name: 'Teams' })
  - waiting for navigation to finish...

Additional context

I have tracked down the issue and mentioned it in this pull request #32899 (comment)

The test works in version 1.48.2.

Environment

System:
    OS: macOS 13.7
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 20.13.1 - /usr/local/bin/node
    npm: 10.8.2 - /usr/local/bin/npm
  Languages:
    Bash: 3.2.57 - /bin/bash
@chrisbottin
Copy link
Author

Duplicate of 33806

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant