playwright: [BUG] page.goto: Navigation failed because page was closed! when executing test in Firefox in headed mode
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?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 1
- Comments: 19 (4 by maintainers)
I had this in the past with page.reload(). It was fixed in a new webkit release I believe. Now I have it again in the latest version of Playwright (1.32.2).
Had the same issue here. My machine is a macOS Ventura and page.goto passed on Webkit and Chrome but fails on the firefox.
I think there is a problem with the firefox driver or something.
This is likely not going to help, however in my case a simple
awaitfixed the problemI use BuddyWorks pipelines and getting “Navigation failed because page was closed!” on any test browser. Works perfectly fine locally, but doesn’t when I try to run simple tests in the pipeline. This is so frustrating.
I also get the same issue when running on github actions!
But I can’t reproduce this in any way on my local! It doesn’t seem to be related to a specific browser, just fails on the 1st on that is set to run the test suite on (it is using only one worker).
Tried using goto with different event listeners and some timeout, but still, no improvements
Happening in ubuntu jammy in next js 13.4. Exact same error. Any fix so far? Other browsers are fine only safari mobile it is crashing
@chundhau Could you please follow this section, but replace
pw:apiwithpw:browser*,pw:api, and then paste the logs here? Make sure to choose a powershell or a batch version, depending on what you use.