Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: An unexpected error occurred: BrowserType.launch: Target page, context or browser has been closed Browser logs: #34879

Open
Bunmi2020 opened this issue Feb 21, 2025 · 4 comments

Comments

@Bunmi2020
Copy link

Bunmi2020 commented Feb 21, 2025

Version

v1.50.1

Steps to reproduce

after creating a Virtual Environment
running the python:

def main():
    with sync_playwright() as p:
        try:
            # Launch browser
            browser = p.chromium.launch(headless=True)  # Set headless=True for faster performance
            context = browser.new_context()
            page = context.new_page()

            # Base URL
            page.goto("https://www.basedonform.com/", timeout=1900000)
            page.wait_for_timeout(5000)  # Wait for the page to load completely
...

Expected behavior

I expected the code to run so it can read my website

Actual behavior

Results in:

An unexpected error occurred: BrowserType.launch: Target page, context or browser has been closed
Browser logs:

Additional context

I would appreciate a concrete solution. Thank you

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 Intel(R) Core(TM) i5-5300U CPU @ 2.30GHz
    Memory: 840.75 MB / 7.88 GB
  Binaries:
    Node: 18.12.1 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.17 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.3.0 - C:\Program Files\nodejs\npm.CMD
@Skn0tt
Copy link
Member

Skn0tt commented Feb 21, 2025

The script completes successfully on my machine. Could you provide me with the browser logs from the error message? Maybe there's something interesting in there.

@Bunmi2020
Copy link
Author

Bunmi2020 commented Feb 21, 2025

@Skn0tt

`Browser logs:

C:\Users\Bunmi\AppData\Local\ms-playwright\chromium_headless_shell-1155\chrome-win\headless_shell.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=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding,ThirdPartyStoragePartitioning,LensOverlay,PlzDedicatedWorker --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 --unsafely-disable-devtools-self-xss-warnings --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=C:\Users\Bunmi\AppData\Local\Temp\playwright_chromiumdev_profile-QruBLW --remote-debugging-pipe --no-startup-window
pid=6924
Call log:

  • C:\Users\Bunmi\AppData\Local\ms-playwright\chromium_headless_shell-1155\chrome-win\headless_shell.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=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding,ThirdPartyStoragePartitioning,LensOverlay,PlzDedicatedWorker --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 --unsafely-disable-devtools-self-xss-warnings --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=C:\Users\Bunmi\AppData\Local\Temp\playwright_chromiumdev_profile-QruBLW --remote-debugging-pipe --no-startup-window
    • pid=6924
      `

@Skn0tt
Copy link
Member

Skn0tt commented Feb 21, 2025

Hmm, there's not much in there. I have no idea what's going wrong on your end, but i'm almost certainly sure that there's something wrong on your machine. My recommendation is to seek help over in our Discord Server: https://aka.ms/playwright/discord

@mxschmitt
Copy link
Member

Could you try setting the DEBUG=pw:browser,pw:protocol env var while you run your script if that yields to any interesting output?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants