[Bug]: Playwright stuck at about:blank instead of opening the test page
Version
1.44.1
Steps to reproduce
I have a very basic new Playwright project setup and all I am doing for now is to try and run a test to open a page. I tried with different URLs and the result is always the same, instead of opening the test page, the browser gets stuck at about:blank.
Here's the config file:
// @ts-check
const { defineConfig, devices } = require('@playwright/test');
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : undefined,
reporter: [['list'], ['html', { open: 'never' }]],
timeout: 60000,
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
baseURL: 'https://www.fedex.com/en-us/',
screenshot: 'only-on-failure',
trace: 'on-first-retry',
viewport: { width: 1440, height: 1080 },
video: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
// {
// name: 'firefox',
// use: { ...devices['Desktop Firefox'] },
// },
// {
// name: 'webkit',
// use: { ...devices['Desktop Safari'] },
// },
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],
});
Here is the test file:
// @ts-check
const { test, expect } = require('@playwright/test');
test.beforeEach('Given I open the en-us homepage', async ({ page }) => {
console.log(`Running ${test.info().title}`);
await page.goto('home.html');
await page.getByRole('link', { name: 'close' }).click();
});
test('Rate & Ship (example test)', async ({ page }) => {
await test.step('When I click the Get Rate and Shipping Details button', async () => {
await page
.getByRole('button', { name: 'Get Rate and Shipping Details' })
.click();
});
await test.step('Then I should see the options for calculating shipping rates displayed', async () => {
await expect(
page.getByRole('heading', { name: 'Calculate FedEx shipping rates' })
).toBeVisible();
await expect(page.getByLabel('From address, type in the')).toBeVisible();
await expect(page.getByLabel('To address, type in the full')).toBeVisible();
});
});
Expected behavior
Bowser navigates to the test page url.
Actual behavior
Error: page.goto: Test timeout of 60000ms exceeded.
Call log:
- navigating to "https://www.fedex.com/en-us/home.html", waiting until "load"
pw:api => selectors.setTestIdAttribute started +0ms
pw:api => browserType.launch started +5ms
pw:api <= selectors.setTestIdAttribute succeeded +8ms
pw:api <= browserType.launch succeeded +285ms
pw:api => browser.newContext started +2ms
pw:api <= browser.newContext succeeded +7ms
pw:api => browserContext.newPage started +3ms
pw:api <= browserContext.newPage succeeded +97ms
Running Rate & Ship (example test)
pw:api => page.goto started +2ms
pw:api navigating to "https://www.fedex.com/en-us/home.html", waiting until "load" +2ms
pw:api => page.screenshot started +30s
pw:api taking page screenshot +2ms
pw:api waiting for fonts to load... +1ms
pw:api fonts loaded +0ms
pw:api <= page.screenshot failed +5s
pw:api <= page.goto failed +9ms
Additional context
If I run it by using the VS Code extension, after a few retries it will start working.
If I run it in the terminal with npx playwright test, it never works.
Also, the page I gave is just an example, I tried with other websites as well and the result is always the same.
Environment
System:
OS: macOS 14.4.1
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 1.24 GB / 32.00 GB
Binaries:
Node: 18.7.0 - ~/.nvm/versions/node/v18.7.0/bin/node
npm: 8.15.0 - ~/.nvm/versions/node/v18.7.0/bin/npm
IDEs:
VSCode: 1.89.1 - /usr/local/bin/code
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/test: ^1.44.1 => 1.44.1
@DanielStoica85 Unfortunately, I cannot reproduce the issue. page.goto() always works for me, but the test is stuck on page.getByRole('link', { name: 'close' }).click() because there is no "close" button on the page.
I'd recommend to use the debugging tools or record a trace and inspect it. We won't be able to help without reproducing the issue.
You can ignore all of the steps that come after page.goto(), because the same thing will happen even if I change to a one step test like opening Google and that's it.
I will try what you suggested and get back to you.
@DanielStoica85 Unfortunately, I cannot reproduce the issue.
page.goto()always works for me, but the test is stuck onpage.getByRole('link', { name: 'close' }).click()because there is no "close" button on the page.I'd recommend to use the debugging tools or record a trace and inspect it. We won't be able to help without reproducing the issue.
I tried recording a trace and even opening the trace gives me a similar error:
npx playwright show-trace test-results/rate-ship-Rate-Ship-example-test--chromium/trace.zip
TimeoutError: Timeout 30000ms exceeded.
Later update: opening the trace only works from the report, but I can't see anything helpful. Can you please suggest what I should look for?
And one more update: even the test shown below fails for the same reason.
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});
I noticed something else that might be helpful.
So like I said, navigation fails at first attempt, even when running the test by using the VS code extension. But after failing for the first time, if you rerun (without closing the browser) it will work on second attempt. And third, and so on... As long as you do not close the browser!
But then if you close the browser again and trigger a run, it will fail again at first attempt and you have to restart the process of retrying.
All of this happens when running with the VS Code extension. When running from the terminal, it always fails.
Debugging in UI mode is also impossible to do because it gets stuck like this:
@DanielStoica85 All the symptoms suggest that the browser is having troubles loading.
- In the trace viewer, try looking at the network tab - do you see anything there?
- Separately, try running in the terminal with
DEBUG=pw:browser npx playwright testto see whether the browser has some interesting output.
Thanks for getting back to me!
All I see in the trace viewer (network tab) is this:
As for your second suggestion, this is what I get:
pw:browser <launched> pid=29779 +7ms
pw:browser [pid=29779] <gracefully close start> +35s
pw:browser [pid=29779] <process did exit: exitCode=0, signal=null> +10s
pw:browser [pid=29779] starting temporary directories cleanup +0ms
pw:browser [pid=29779] finished temporary directories cleanup +13ms
pw:browser [pid=29779] <gracefully close end> +1ms
@DanielStoica85 Interesting! There are no browser errors, but the network request is stuck forever. Perhaps you've got a firewall or a corporate proxy that does not let the network requests through? Maybe you should add Playwright's Chromium binary to some list of exceptions?
One more suggestion is to try with the Google Chrome browser. Change your config like this:
...
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
If a network proxy/firewall would be the problem, then it would never work. But like I explained above, after failing for the first time, if you rerun (without closing the browser) it will work on second attempt. And third, and so on... As long as you do not close the browser! Only when running from the terminal, it never works.
This was the result when running with Chrome browser:
pw:browser <launched> pid=71980 +6ms
pw:browser [pid=71980] <gracefully close start> +35s
pw:browser [pid=71980] <process did exit: exitCode=0, signal=null> +10s
pw:browser [pid=71980] starting temporary directories cleanup +1ms
pw:browser [pid=71980] finished temporary directories cleanup +14ms
pw:browser [pid=71980] <gracefully close end> +0ms
@DanielStoica85 Unfortunately, I am out of ideas at this point. I'll keep the issue open for some time, just in case someone would have an idea. If you gather more information that could be helpful, please comment here.
I ran into the same issue, it has something to do with the test name of test.info / annotation - try renaming the tests and removing all annotations.
same code that exhibited thisbehaviour, when moved to a different test with a different name (in same describe bracket) worked fine.
so something is buggy in there.
same code that exhibited thisbehaviour, when moved to a different test with a different name (in same describe bracket) worked fine.
so something is buggy in there.
For me it fails even if I use the example test that Playwright gives.
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});
@DanielStoica85 could you please give us the output of npx playwright --version?
Is your machine corp-hosted / managed by some company policies? Or do you have special anti-virus software on your machine?
@DanielStoica85 could you please give us the output of
npx playwright --version?Is your machine corp-hosted / managed by some company policies? Or do you have special anti-virus software on your machine?
Sure.
Version 1.44.1
As for the second question: the laptop is indeed managed by some company policies and there is company software installed on it (not just anti-virus). But if that would be the problem, wouldn't it always fail?
Ah, might also be worth mentioning that I tried another Playwright project created at my company and that one works. One main difference is that it uses a specific (older) version of Playwright: 1.33.0.
As for the second question: the laptop is indeed managed by some company policies and there is company software installed on it (not just anti-virus). But if that would be the problem, wouldn't it always fail?
Absolutely! But that might depend on what exactly is inferring with it. Your config uses Chromium - so ideally no enterprise policies apply there. If we are talking about Chrome policies, they usually only apply to Google Chrome and Microsoft Edge.
Ah, might also be worth mentioning that I tried another Playwright project created at my company and that one works. One main difference is that it uses a specific (older) version of Playwright: 1.33.0.
It might be worth trying the following:
- go over the Playwright versions to find out which one was the last one which was working.
- make sure it works / or not with a newly created project: https://playwright.dev/docs/intro
Appreciate the digging - since we unfortunately run out of ideas here.
Hey @mxschmitt !
Thanks a lot for still trying to help, I know it almost seems like a hopeless situation, but I am not ready to give up just yet, haha. :)
- Yes, I mostly use Chromium, but I also tried with the other two and the result was the same.
- I already tried with a new project. Even this one was a new project a few days ago. The end-result is always the same, even if I just run the example test that gets added by Playwright when initializing a new project.
- I started going down in versions one by one and here is what happened:
- when I got to version 1.37.1, it seemed like there might be some hope, as it was working in around 1 out of 3-4 tries, but that was it - it might have been just a coincidence, as even with the latest version it does work in the terminal from time to time (very rarely);
- I went all the way to 1.33.0 and I decided to stop there. If you think I should try even lower versions, I can do that. The only "improvement" I saw while doing all of this was that for some versions it works intermittently (in 1 out of 3-4 attempts), but this is not very helpful.
Not sure what else to try.
We have the same issue with out tests. Some tests randomly timeout, some are interrupted. There is no pattern - each time it's a different set of failed test. Most of them fails on goto call. It does not matter if we run headlees mode or not.
Playwright: 1.45.3 Chrome: 127.0.6533.120 (Official Build) (64-bit)
Not sure if anything else can help to solve the issues.
Noticed that this is prob. an error "40" (reason for the error is 40cm infront of the screen).If you use fixtures and the accidentially pass page in constructor context is switched and a new page is created.Same thin is you dhare page amongst test for long loading scenariosOn 20 Aug 2024, at 17.26, Alex Fioletov @.***> wrote: We have the same issue with out tests. Some tests randomly timeout, some are interrupted. There is no pattern - each time it's a different set of failed test. Most of them fails on goto call. It does not matter if we run headlees mode or not. image.png (view on web) image.png (view on web) Playwright: 1.45.3 Chrome: 127.0.6533.120 (Official Build) (64-bit) Not sure if anything else can help to solve the issues.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
In our case it was an error "40" indeed. Tests were running against vite in dev mode and slow loading causes issues.
I suddenly started running into this issue after upgrading from Playwright v1.46.1 to v1.47.0. It's very random (happens once in ~50% of my runs, but I have hundreds of tests) but always, so far, happens on Webkit.
Hi, I'm having the same issue: It is forever stuck at about:blank. I can recreate this error with the following steps:
yarn create next-app # default values
cd my-app
yarn create playwright # default values
yarn playwright test # headless runs fine, 6 passed (3.6s)
yarn playwright test --debug # stuck at about:blank, no timeout
- playwright 1.47.0
- next.js 14.2.9
- OS: Ubuntu 22.04.5 LTS
I also tried in a virtual machine, same error.
I noticed that the Playwright Inspector window seems to be paused:
And if I resume it, clicking the play button for every test:
It succeeds:
Running 6 tests using 1 worker
Slow test file: [chromium] › example.spec.ts (3.5m)
Slow test file: [firefox] › example.spec.ts (15.2s)
Consider splitting slow test files to speed up parallel execution
6 passed (3.9m)
playwright = "1.45.0"
Hello, have similar issue: after test click on locator browser stuck on about:blank, but it should just update small part of page. If try to take scennshot you have traceback like this and gitlab job crashes
INTERNALERROR> Traceback (most recent call last):
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 270, in wrap_session
INTERNALERROR> session.exitstatus = doit(config, session) or 0
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 324, in _main
INTERNALERROR> config.hook.pytest_runtestloop(session=session)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 182, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_result.py", line 100, in get_result
INTERNALERROR> raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/_pytest/main.py", line 349, in pytest_runtestloop
INTERNALERROR> item.config.hook.pytest_runtest_protocol(item=item, nextitem=nextitem)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 182, in _multicall
INTERNALERROR> return outcome.get_result()
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_result.py", line 100, in get_result
INTERNALERROR> raise exc.with_traceback(exc.__traceback__)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 103, in _multicall
INTERNALERROR> res = hook_impl.function(*args)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pytest_rerunfailures.py", line 541, in pytest_runtest_protocol
INTERNALERROR> reports = runtestprotocol(item, nextitem=nextitem, log=False)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 131, in runtestprotocol
INTERNALERROR> reports.append(call_and_report(item, "call", log))
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/_pytest/runner.py", line 222, in call_and_report
INTERNALERROR> report: TestReport = hook.pytest_runtest_makereport(item=item, call=call)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_hooks.py", line 513, in __call__
INTERNALERROR> return self._hookexec(self.name, self._hookimpls.copy(), kwargs, firstresult)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_manager.py", line 120, in _hookexec
INTERNALERROR> return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/pluggy/_callers.py", line 156, in _multicall
INTERNALERROR> teardown[0].send(outcome)
INTERNALERROR> File "/home/gitlab-runner/disk/builds/xaAeWzKK/0/bububu/project_name/conftest.py", line 777, in pytest_runtest_makereport
INTERNALERROR> screenshot = page.screenshot(path=f"{full_path}")
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/playwright/sync_api/_generated.py", line 9543, in screenshot
INTERNALERROR> self._sync(
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_sync_base.py", line 115, in _sync
INTERNALERROR> return task.result()
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_page.py", line 739, in screenshot
INTERNALERROR> encoded_binary = await self._channel.send("screenshot", params)
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 59, in send
INTERNALERROR> return await self._connection.wrap_api_call(
INTERNALERROR> File "/usr/local/lib/python3.10/dist-packages/playwright/_impl/_connection.py", line 514, in wrap_api_call
INTERNALERROR> raise rewrite_error(error, f"{parsed_st['apiName']}: {error}") from None
INTERNALERROR> playwright._impl._errors.Error: Page.screenshot: Target crashed
INTERNALERROR> Call log:
INTERNALERROR> taking page screenshot
INTERNALERROR> - waiting for fonts to load...
INTERNALERROR> - fonts loaded
if i catch an exception:
try:
screenshot = page.screenshot(path=f"{full_path}")
except Exception:
logger.info("Cant make screenshot")
i can see that pw try to make a screenshot of blank page for 1 hour and look like all next tests fail with same problem after this
I'm experiencing something similar. At work we are on version 1.47.0 and yesterday we setup a self hosted Github action runner. So far I have done 7 runs of our tests. Only 1 out of the 7 has been successful. All tests passed (no flakes) in that one successful run. I have had to cancel the other 6 runs because one test would randomly fail, then every test after that would timeout on beforeEach with no code being executed at all.
Looking at the traces of the failures and retries. It's just a about:blank page:
Here are some screenshots of the logs. All those tests that have a runtime of 30.0s have the exact same trace as the one in the screenshot above:
As I'm writing this, I'm on test run number 8 after upgrading to 1.48.0 and also disabling trace but the issue is still there so I'll have to cancel this run again.
Let me try downgrading to see if that will fix the issue. Btw all the runs are being executed by 1 worker only.
So I've run it with DEBUG=pw:browser and here are the logs when it launches:
And here are the logs when the tests start failing:
I've experienced similar issues; sometimes the navigation to the URL succeeds, and other times it fails. It seems to be related to some specific website, as I haven't encountered any failures when navigating to other websites.
Is this getting fixed? Was excited to try some load testing with playwright, but I can't even open a chromium page.
This all happens when I run npx playwright test --trace on from terminal
Page opens to "about:blank" on chromium, Google Chrome, and Microsoft Edge. "about:blank" doesn't get replaced by the URL and hangs until timeout.
Page link opens properly when I use firefox and webkit
playwright --version : 1.48.0 npx --version: 10.7.0 OS: Windows 10
The error:
Here with firefox the same about:blank, but it looks like the call to page.goto() after works. page.goto() never gets called it seems for chromium based browsers.
My Test:
import { test, expect } from '@playwright/test';
test('has title', async ({ page }) => {
await page.goto('https://playwright.dev/');
// Expect a title "to contain" a substring.
await expect(page).toHaveTitle(/Playwright/);
});
My Config:
import { defineConfig, devices } from '@playwright/test';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// import dotenv from 'dotenv';
// import path from 'path';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
/**
* See https://playwright.dev/docs/test-configuration.
*/
module.exports = defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
// baseURL: 'http://127.0.0.1:3000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
/* Test against branded browsers. */
//{
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
//},
//{
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
//},
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'npm run start',
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },
});
I'm quite new to Playwright and just experienced this issue with my first test. I was trying to open a second tab and was getting stuck at about:blank URL and solved it with 2 things:
- Changing the config from Chrome to Firefox:
use: { ...devices['Desktop Firefox'] }, - And changing the URL in the code From this way:
await newTab.waitForURL('https://expected-url-here');to this:await newTab.waitForURL(/expected-url-here);
It worked for me!
Happens for me as well, the same about:blank page opens up and nothing happens. But for me it's usually happening after I run the test second time from VS code extension or when I have a setup project that runs okay, but after that another browser window opens with about:blank and tests stuck.
It isn't very pleasant, I can't use any setup and need to run everything with each test.
I had the same problem, but I was able to avoid it by changing the verification browser from chromium to Google Chrome.
// playwright.config.js
...
projects: [
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
],
}
I don't know why it works with normal Chrome, but I think it's not a big problem because the only difference is whether it's headless or not.
For me, it only happens with tests using a custom fixture.