playwright: [Bug]: Cannot open ui or run tests with chromium - Error: browserType.launch: Target page, context or browser has been closed
Version
1.41.2
Steps to reproduce
similar to issue https://github.com/microsoft/playwright/issues/28500
System info Playwright Version: 1.41.2 Operating System: Mac Node.js version: v20.3.0 Browser: Chromium Reproduces: always
Source code Just installed Playwright and I’m using the test files, haven’t made any changes (demo-todo-app.spec.ts and example.spec.ts)
Steps
When running npx playwright test --ui, I’m getting the following:
ProtocolError: Protocol error (Browser.getVersion): Internal server error, session closed.
When runningnpx playwright test, I’m getting errors on all Chromium test runs. Firefox and Webkit work fine.
Expected behavior
Can use UI mode, tests pass in chrome
Actual behavior
`Error: browserType.launch: Target page, context or browser has been closed Browser logs:
<launching> /Users/myUser/Library/Caches/ms-playwright/chromium-1097/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --enable-use-zoom-for-dsf=false --use-angle --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/var/folders/0_/kqkw512574d2xn91pntrmkmr0000gn/T/playwright_chromiumdev_profile-IhHsV9 --remote-debugging-pipe --no-startup-window <launched> pid=28962 Call log:
- <launching> /Users/myUser/Library/Caches/ms-playwright/chromium-1097/chrome-mac/Chromium.app/Contents/MacOS/Chromium --disable-field-trial-config --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --enable-use-zoom-for-dsf=false --use-angle --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/var/folders/0_/kqkw512574d2xn91pntrmkmr0000gn/T/playwright_chromiumdev_profile-IhHsV9 --remote-debugging-pipe --no-startup-window
- <launched> pid=28962`
Additional context
I’ve tried npx playwright install --with-deps chromium, npx playwright install and the most recent canary release to no avail. Cypress runs with Chrome work fine, so doesn’t seem to be a firewall issue. I’ve tried using version 1.40.1, which worked fine on January 3 when I first installed Playwright, but does not seem to be working any more either.
Environment
System:
OS: macOS 14.3
CPU: (16) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
Memory: 2.27 GB / 16.00 GB
Binaries:
Node: 20.3.0 - /usr/local/bin/node
npm: 9.6.7 - /usr/local/bin/npm
Languages:
Bash: 3.2.57 - /bin/bash
npmPackages:
@playwright/test: ^1.41.2 => 1.41.2
playwright: ^1.41.2 => 1.41.2
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 33 (7 by maintainers)
Seems like it’s a caching issue. Just delete this directory
/Users/myUser/Library/Caches/ms-playwright/and try to run the test again. Works on my case.Re-opened issue
I was having the exact same issue with a completely new Playwright project running on a a Hyper-V virtual machine. Running
npx playwright test --ui-host=0.0.0.0as described in their docs (https://playwright.dev/docs/test-ui-mode#docker--github-codespaces) seems to resolve the problem. At least it did for me.I am getting the issue on 1.52.0 on Windows, but it appears to be only if I run it from a console opened with “Run as Administrator”
Yes, for me the last working version is 1.52.x, I’ve checked and still broken with 1.54. Browser just crashed in Browser.getVersion call . interesting that
npx playwright open https://google.comworks fine, butplaywright test --uidoesn’t work even on empty project:@mxschmitt reopen this please, because it’s much simpler to find
Hi! The same problem on @playwright/test": "^1.53.1
I tried deleting the folder /Users/myUser/Library/Caches/ms-playwright and then reinstalling Playwright, but it didn’t help.
ProtocolError: Protocol error (Browser.getVersion): Internal server error, session closed. at \node_modules\playwright-core\lib\server\chromium\crConnection.js:116:57 at new Promise (<anonymous>) at CRSession.send (\node_modules\playwright-core\lib\server\chromium\crConnection.js:115:12) at Function.connect (\node_modules\playwright-core\lib\server\chromium\crBrowser.js:77:35) at Chromium.connectToTransport (\node_modules\playwright-core\lib\server\chromium\chromium.js:126:47) at Chromium._innerLaunch (\node_modules\playwright-core\lib\server\browserType.js:154:32) at Chromium._innerLaunchWithRetries (\node_modules\playwright-core\lib\server\browserType.js:117:14) at \node_modules\playwright-core\lib\server\browserType.js:107:24 at ProgressController.run (\node_modules\playwright-core\lib\server\progress.js:80:22) at Chromium.launchPersistentContext (\node_modules\playwright-core\lib\server\browserType.js:98:21) at launchApp (\node_modules\playwright-core\lib\server\launchApp.js:54:19) at openTraceViewerApp (\node_modules\playwright-core\lib\server\trace\viewer\traceViewer.js:150:29) at \node_modules\playwright\lib\runner\testServer.js:398:20 at innerRunTestServer (\node_modules\playwright\lib\runner\testServer.js:436:5) at Object.runUIMode (\node_modules\playwright\lib\runner\testServer.js:392:10) at runTests (\node_modules\playwright\lib\program.js:171:21) at t.<anonymous> (\node_modules\playwright\lib\program.js:57:7) { type: 'closed', method: 'Browser.getVersion', logs: '\n' + '<launching> \\ms-playwright\\chromium-1179\\chrome-win\\chrome.exe --disable-field-trial-config --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-back-forward-cache --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-component-update --no-default-browser-check --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=AcceptCHFrame,AutoExpandDetailsElement,AvoidUnnecessaryBeforeUnloadCheckSync,CertificateTransparencyComponentUpdater,DestroyProfileOnBrowserClose,DialMediaRouteProvider,ExtensionManifestV2Disabled,GlobalMediaControls,HttpsUpgrades,ImprovedCookieControls,LazyFrameLoading,LensOverlay,MediaRouter,PaintHolding,ThirdPartyStoragePartitioning,Translate --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --force-color-profile=srgb --metrics-recording-only --no-first-run --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --disable-search-engine-choice-screen --unsafely-disable-devtools-self-xss-warnings --no-sandbox --app=data:text/html, --window-size=1280,800 --test-type= --user-data-dir=\\playwright_chromiumdev_profile-3IYgX7 --remote-debugging-pipe about:blank\n' + '<launched> pid=25572' }I don’t have that env variable in
.zshrcand I still get that error 😕Edit: Update to PW
^1.47.0helpedFrom what I can tell, it may be related to the
APIRequestContextbeing included in a wrapper class that is instantiated in thebeforeAll()and then referenced in a test. Is that a valid use case? It fails any time theAPIRequestContext’spostmethod is referenced within a test.