question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] page.goto: Navigation failed because page was closed! when executing test in Firefox in headed mode

See original GitHub issue

Context:

  • Playwright Version: 1.23.2
  • Operating System: Windows
  • Node.js version: 12.18.3
  • Browser: firefox
  • Extra:

Config File

const config = {
    outputDir: './test-results',
    use: {
      baseURL: 'http://localhost:5500',
      browserName: 'firefox',
      headless: false,
      viewport: { width: 600, height: 800 },
      video: 'on',
      launchOptions: {
        slowMo: 500,
      },
    },
  };
  
  module.exports = config;

Test File

const { test, expect } = require('@playwright/test');

//Menu opens when clicked
test('open menu', async ({ page }) => {
  await page.goto(''); 
  await page.locator('#menuBtn').click();
  await expect(page.locator('#sideMenu')).toBeVisible();
});

Describe the bug The test succeeds when I set the browserName to either chromium or webkit in the config file, but fails when I set browserName to firefox in the config file. When the test fails, I see this error:

PS C:\dev\book\speedscore> npx playwright test

Running 1 test using 1 worker

  ✘  tests\menuVisualTests.spec.js:4:1 › open menu (2s)


  1) tests\menuVisualTests.spec.js:4:1 › open menu =================================================

    page.goto: Navigation failed because page was closed!
    =========================== logs ===========================
    navigating to "http://localhost:5500/", waiting until "load"
    ============================================================

      3 | //Menu opens when clicked
      4 | test('open menu', async ({ page }) => {
    > 5 |   await page.goto(''); 
        |              ^
      6 |   await page.locator('#menuBtn').click();
      7 |   await expect(page.locator('#sideMenu')).toBeVisible();
      8 | });

        at C:\dev\book\speedscore\tests\menuVisualTests.spec.js:5:14
        at C:\dev\book\speedscore\node_modules\@playwright\test\lib\workerRunner.js:388:15
        at TestInfoImpl._runFn (C:\dev\book\speedscore\node_modules\@playwright\test\lib\testInfo.js:166:7)
        at C:\dev\book\speedscore\node_modules\@playwright\test\lib\workerRunner.js:344:26
        at TimeoutManager.runWithTimeout (C:\dev\book\speedscore\node_modules\@playwright\test\lib\timeoutManager.js:70:7)
        at TestInfoImpl._runWithTimeout (C:\dev\book\speedscore\node_modules\@playwright\test\lib\testInfo.js:154:26)
        at WorkerRunner._runTest (C:\dev\book\speedscore\node_modules\@playwright\test\lib\workerRunner.js:326:5)
        at WorkerRunner.runTestGroup (C:\dev\book\speedscore\node_modules\@playwright\test\lib\workerRunner.js:195:11)
        at process.<anonymous> (C:\dev\book\speedscore\node_modules\@playwright\test\lib\worker.js:87:5)


  1 failed
    tests\menuVisualTests.spec.js:4:1 › open menu ==================================================

Pretty strange, huh?

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
dgozmancommented, Jul 18, 2022

@chundhau Could you please follow this section, but replace pw:api with pw:browser*,pw:api, and then paste the logs here? Make sure to choose a powershell or a batch version, depending on what you use.

0reactions
dgozmancommented, Jul 21, 2022

Closing because we lack the information to act on this issue. If you can provide a full repro, please file a new issue with it, and link to this one.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when calling await browser.close(): (node:4960 ...
The reason is page.goto returns a Promise but as it waits for the load event to resolve it: the navigation to the 2nd...
Read more >
navigation failed because page was closed! - You.com
The code above results in a failed test with the message "page.goto: ... failed because page was closed! when executing test in Firefox...
Read more >
Setting up your own test automation environment
To show how to set up a Selenium testing environment locally and run tests with it, and how to integrate it with tools...
Read more >
Use Playwright to automate and test in Microsoft Edge
Use Playwright to automate and test in Microsoft Edge. The Playwright library provides cross-browser automation through a single API.
Read more >
Frame | Playwright - CukeTest
At every point of time, page exposes its current frame tree via the page. ... If no elements match the selector, the method...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found