playwright icon indicating copy to clipboard operation
playwright copied to clipboard

[BUG] "Browser has been closed" error when running test that uses `context.route` and `context.waitForEvent` with playwright vscode extension with "Show browser" enabled

Open DetachHead opened this issue 2 years ago • 5 comments

System info

  • Playwright Version: 1.30.0
  • Operating System: windows 10
  • Browser: chromium

Source code

  • [X] I provided exact source code that allows reproducing the issue locally.

Config file

// playwright.config.ts
export default {}

Test file (self-contained)

test('asdf', async ({ context, page }) => {
    await page.setContent(
        "<button onclick=\"window.open('https://www.google.com', '_blank')\">asdf</button>",
    )
    await context.route(/\/asdf/u, () => {})
    const newPagePromise = context.waitForEvent('page')
    await page.click('button')
    await newPagePromise
})

Steps

  1. enable "Show browser" in the playwright extension options on vscode's "Testing" tab
  2. click the gutter run button next to the test

Expected test passes

Actual "Browser has been closed" error image

this only occurs when running the test through the vscode extension with "Show browser" enabled. the test passes when disabling "Show browser" or when running the test with the playwright test command

DetachHead avatar Apr 13 '23 03:04 DetachHead

@DetachHead update Playwright to latest release 1.32.3 and confirm that bug still apears

jaktestowac avatar Apr 13 '23 07:04 jaktestowac

I tried to reproduce it on macOS, unfortunately I was not able to reproduce it. It might play a role that you are on Windows, are some of your colleagues on Windows by any chance?

Also having a full repro repository might play a role here.

mxschmitt avatar Apr 13 '23 12:04 mxschmitt

i think the issue was intermittent but i can't seem to reproduce it anymore. will re-open if it happens again

DetachHead avatar Apr 14 '23 01:04 DetachHead

I have the same issue here on Ubuntu 22.04.

Playwright ver 1.33.0.

[1/1] [chromium] › fcnf-1312-multilanguage/checkout.spec.js:33:5 › 001-change-eng-to-indo
  1) [chromium] › fcnf-1312-multilanguage/checkout.spec.js:33:5 › 001-change-eng-to-indo ───────────

    Test timeout of 30000ms exceeded.

    Pending operations:
      - page.goto at e2e/fcnf-1312-multilanguage/checkout.spec.js:136:16


    Error: page.goto: Browser has been closed

      134 |
      135 |   await test.step('test-with-items-on-cart', async () => {
    > 136 |     await page.goto('https://someurl.sh', {timeout: 30000});
          |                ^
      137 |     await expect(page).toHaveURL(/.*someurl/, {timeout: 30000});
      138 |     await page.getByRole('link', { name: 'Roma Slai O\'lai Pineapple 192 Gram' }).first().click();
      139 |     await page.getByRole('button', { name: '1-Click Checkout' }).click();

        at /home/imanovski/Project/flik/flik-checkout-e2e/e2e/fcnf-1312-multilanguage/checkout.spec.js:136:16
        at /home/imanovski/Project/flik/flik-checkout-e2e/e2e/fcnf-1312-multilanguage/checkout.spec.js:135:14


  1 failed
    [chromium] › fcnf-1312-multilanguage/checkout.spec.js:33:5 › 001-change-eng-to-indo ────────────

But it's look intermitent.

rimantoro avatar May 16 '23 00:05 rimantoro

@rimantoro Do you happen to have a trace, browser logs, or something else that could help? Unfortunately, without a repro there's not much we can do here.

dgozman avatar May 17 '23 23:05 dgozman

Closing because we lack the information to act on this issue. If you can provide a full repro, please file a new issue by filling the "Bug Report" template, and link to this one.

dgozman avatar May 19 '23 17:05 dgozman

@dgozman here.s a trace where it happens. might not help though, since the trace doesn't go till the end. the test did run one test step further as shown in vsode

image trace.zip

doktordirk avatar Jun 16 '23 10:06 doktordirk