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

browser closed automatically while running python playwright script. even we cannot launch single page #16290

Closed
Gopala7721 opened this issue Aug 5, 2022 · 13 comments

Comments

@Gopala7721
Copy link

Gopala7721 commented Aug 5, 2022

Context:

  • Playwright Version: 1.20.1
  • Operating System: macos monterey version(12.4 (21F79))
  • python version: 3.8.6
  • Browser: chromium
  • Extra: running below docker commands before executing the script:
    docker-compose -f docker-compose_linux.yml up --detach ccs-dev ccs-pg ccs-redis ccs-kafka
    docker-compose exec -u dev ccs-dev bash -l

Code Snippet

from playwright.sync_api import Playwright, sync_playwright, expect
def run(playwright: Playwright) -> None:
    browser = playwright.chromium.launch(headless=True)
    context = browser.new_context()
    # Open new page
    page = context.new_page()
    page.goto("https://polaris.ccs.arubathena.com/")
    page.locator("input[name=\"username\"]").click()
    page.locator("input[name=\"username\"]").fill("[email protected]")
    with page.expect_navigation():
        page.locator("text=Next").click()
    page.locator("input[name=\"password\"]").fill("12345")
   
    with page.expect_navigation():
        page.locator("input:has-text(\"Sign In\")").click()
    context.close()
    browser.close()
with sync_playwright() as playwright:
    run(playwright)

Note: tried with both headed and headless . tried with PWDEBUG=""

@Gopala7721
Copy link
Author

Gopala7721 commented Aug 5, 2022

Virtualenv
Python: 3.8.6
Implementation: CPython
Path: /usr/local/lib/ccs-dev/poetry/venvs/hpe-authz-ft-0vU6W4PJ-py3.8
Valid: True

System
Platform: linux
OS: posix
Python: /opt/pyenv/versions/3.8.6
dev@ccs-dev:~/../../../tests/ui_test$

@Gopala7721 Gopala7721 changed the title browser closed automatically without starting executing the script. browser closed automatically while running python playwright script: Aug 5, 2022
@Gopala7721
Copy link
Author

/tests/ui_test$ uname -a
Linux ccs-dev 5.10.104-linuxkit #1 SMP PREEMPT Wed Mar 9 19:01:25 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
dev@ccs-dev:~/repo/ws/stash.arubanetworks.com/ccs/authz/tests/ui_test$

@Gopala7721
Copy link
Author

Error:

plugins: base-url-2.0.0, playwright-0.3.0
collected 0 items / 1 error                                                                                                                                                             

======================================================================================== ERRORS =========================================================================================
_________________________________________________________________________ ERROR collecting testcases/test_ui.py _________________________________________________________________________
testcases/test_ui.py:19: in <module>
    run(playwright)
testcases/test_ui.py:6: in run
    page = context.new_page()
/opt/pyenv/versions/3.8.6/lib/python3.8/site-packages/playwright/sync_api/_generated.py:10119: in new_page
    self._sync("browser_context.new_page", self._impl_obj.new_page())
/opt/pyenv/versions/3.8.6/lib/python3.8/site-packages/playwright/_impl/_browser_context.py:199: in new_page
    return from_channel(await self._channel.send("newPage"))
/opt/pyenv/versions/3.8.6/lib/python3.8/site-packages/playwright/_impl/_connection.py:39: in send
    return await self.inner_send(method, params, False)
/opt/pyenv/versions/3.8.6/lib/python3.8/site-packages/playwright/_impl/_connection.py:63: in inner_send
    result = next(iter(done)).result()
E   playwright._impl._api_types.Error: Browser closed.
E   ==================== Browser output: ====================
E   <launching> /home/dev/.cache/ms-playwright/chromium-978106/chrome-linux/chrome --disable-background-networking --enable-features=NetworkService,NetworkServiceInProcess --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-breakpad --disable-client-side-phishing-detection --disable-component-extensions-with-background-pages --disable-default-apps --disable-dev-shm-usage --disable-extensions --disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater --allow-pre-commit-input --disable-hang-monitor --disable-ipc-flooding-protection --disable-popup-blocking --disable-prompt-on-repost --disable-renderer-backgrounding --disable-sync --force-color-profile=srgb --metrics-recording-only --no-first-run --enable-automation --password-store=basic --use-mock-keychain --no-service-autorun --export-tagged-pdf --headless --hide-scrollbars --mute-audio --blink-settings=primaryHoverType=2,availableHoverTypes=2,primaryPointerType=4,availablePointerTypes=4 --no-sandbox --user-data-dir=/tmp/playwright_chromiumdev_profile-rvOd92 --remote-debugging-pipe --no-startup-window
E   <launched> pid=9205
E   [pid=9205][err] [0805/055543.467291:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
E   [pid=9205][err] [0805/055543.848743:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
E   [pid=9205][err] [0805/055543.849260:ERROR:stack_trace_posix.cc(707)] Failed to parse the contents of /proc/self/maps
E   [pid=9205][err] [0805/055543.874935:FATAL:zygote_main_linux.cc(161)] Check failed: sandbox::ThreadHelpers::IsSingleThreaded(). 
E   [pid=9205][err] #0 0x004006f3a369 <unknown>
E   [pid=9205][err] #1 0x004006ea08c3 <unknown>
E   [pid=9205][err] #2 0x004006eb3650 <unknown>
E   [pid=9205][err] #3 0x004006eb41fe <unknown>
E   [pid=9205][err] #4 0x004006a57046 <unknown>
E   [pid=9205][err] #5 0x004006a51fc0 <unknown>
E   [pid=9205][err] #6 0x004006a52be9 <unknown>
E   [pid=9205][err] #7 0x004006a5387b <unknown>
E   [pid=9205][err] #8 0x004006a50cb4 <unknown>
E   [pid=9205][err] #9 0x004006a515ce <unknown>
E   [pid=9205][err] #10 0x004006aacc5a <unknown>
E   [pid=9205][err] #11 0x004006aacb13 <unknown>
E   [pid=9205][err] #12 0x004006aab755 <unknown>
E   [pid=9205][err] #13 0x004003571fa8 <unknown>
E   [pid=9205][err] #14 0x0040130bdbf7 <unknown>
E   [pid=9205][err] #15 0x004003571dea <unknown>
E   [pid=9205][err] 
E   [pid=9205][err] qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
E   [pid=9205][err] [0805/055543.876618:FATAL:zygote_main_linux.cc(161)] Check failed: sandbox::ThreadHelpers::IsSingleThreaded(). 
E   [pid=9205][err] #0 0x004006f3a369 <unknown>
E   [pid=9205][err] #1 0x004006ea08c3 <unknown>
E   [pid=9205][err] #2 0x004006eb3650 <unknown>
E   [pid=9205][err] #3 0x004006eb41fe <unknown>
E   [pid=9205][err] #4 0x004006a57046 <unknown>
E   [pid=9205][err] #5 0x004006a51fc0 <unknown>
E   [pid=9205][err] #6 0x004006a52be9 <unknown>
E   [pid=9205][err] #7 0x004006a5387b <unknown>
E   [pid=9205][err] #8 0x004006a50cb4 <unknown>
E   [pid=9205][err] #9 0x004006a515ce <unknown>
E   [pid=9205][err] #10 0x004006aacc5a <unknown>
E   [pid=9205][err] #11 0x004006aacb13 <unknown>
E   [pid=9205][err] #12 0x004006aab755 <unknown>
E   [pid=9205][err] #13 0x004003571fa8 <unknown>
E   [pid=9205][err] #14 0x0040130bdbf7 <unknown>
E   [pid=9205][err] #15 0x004003571dea <unknown>
E   [pid=9205][err] 
E   [pid=9205][err] qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
E   [pid=9205][err] [0805/055544.929221:ERROR:file_path_watcher_linux.cc(321)] inotify_init() failed: Function not implemented (38)
E   [pid=9205][err] [0805/055545.086236:WARNING:bluez_dbus_manager.cc(248)] Floss manager not present, cannot set Floss enable/disable.
E   [pid=9205][err] [0805/055545.086578:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.086674:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 1 time(s)
E   [pid=9205][err] [0805/055545.121484:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.121553:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 2 time(s)
E   [pid=9205][err] [0805/055545.136492:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.136567:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 3 time(s)
E   [pid=9205][err] [0805/055545.141324:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.141369:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 4 time(s)
E   [pid=9205][err] [0805/055545.175661:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.175725:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 5 time(s)
E   [pid=9205][err] [0805/055545.196348:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.196420:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 6 time(s)
E   [pid=9205][err] [0805/055545.206703:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.206754:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 7 time(s)
E   [pid=9205][err] [0805/055545.240318:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.240390:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 8 time(s)
E   [pid=9205][err] [0805/055545.253882:ERROR:gpu_process_host.cc(968)] GPU process launch failed: error_code=1002
E   [pid=9205][err] [0805/055545.253932:WARNING:gpu_process_host.cc(1279)] The GPU process has crashed 9 time(s)
E   [pid=9205][err] [0805/055545.253987:FATAL:gpu_data_manager_impl_private.cc(447)] GPU process isn't usable. Goodbye.
E   [pid=9205][err] #0 0x004006f3a369 <unknown>
E   [pid=9205][err] #1 0x004006ea08c3 <unknown>
E   [pid=9205][err] #2 0x004006eb3650 <unknown>
E   [pid=9205][err] #3 0x004004aa2bf7 <unknown>
E   [pid=9205][err] #4 0x004004aa03fe <unknown>
E   [pid=9205][err] #5 0x004004a9f303 <unknown>
E   [pid=9205][err] #6 0x004004aa9d13 <unknown>
E   [pid=9205][err] #7 0x004004aaaf44 <unknown>
E   [pid=9205][err] #8 0x004004925421 <unknown>
E   [pid=9205][err] #9 0x00400497faf5 <unknown>
E   [pid=9205][err] #10 0x00400497fd15 <unknown>
E   [pid=9205][err] #11 0x004006ef8bb0 <unknown>
E   [pid=9205][err] #12 0x004006f0ca99 <unknown>
E   [pid=9205][err] #13 0x004006f0c7bc <unknown>
E   [pid=9205][err] #14 0x004006f0cf92 <unknown>
E   [pid=9205][err] #15 0x004006ebbecf <unknown>
E   [pid=9205][err] #16 0x004006f0d1fe <unknown>
E   [pid=9205][err] #17 0x004006eda3ed <unknown>
E   [pid=9205][err] #18 0x00400493d2ad <unknown>
E   [pid=9205][err] #19 0x00400493eb62 <unknown>
E   [pid=9205][err] #20 0x00400c36683e <unknown>
E   [pid=9205][err] #21 0x004006a52862 <unknown>
E   [pid=9205][err] #22 0x004006a53d0f <unknown>
E   [pid=9205][err] #23 0x004006a5389f <unknown>
E   [pid=9205][err] #24 0x004006a50cb4 <unknown>
E   [pid=9205][err] #25 0x004006a515ce <unknown>
E   [pid=9205][err] #26 0x004006aacc5a <unknown>
E   [pid=9205][err] #27 0x004006aac965 <unknown>
E   [pid=9205][err] #28 0x004003571fa8 <unknown>
E   [pid=9205][err] #29 0x0040130bdbf7 <unknown>
E   [pid=9205][err] #30 0x004003571dea <unknown>
E   [pid=9205][err] Task trace:
E   [pid=9205][err] #0 0x00400497f9ac <unknown>
E   [pid=9205][err] #1 0x00400497f3aa <unknown>
E   [pid=9205][err] #2 0x004007292456 <unknown>
E   [pid=9205][err] #3 0x004007292456 <unknown>
E   [pid=9205][err] #4 0x004007292456 <unknown>
E   [pid=9205][err] Task trace buffer limit hit, update PendingTask::kTaskBacktraceLength to increase.
E   [pid=9205][err] 
E   [pid=9205][err] qemu: uncaught target signal 5 (Trace/breakpoint trap) - core dumped
================================================================================ short test summary info ================================================================================
ERROR testcases/test_ui.py - playwright._impl._api_types.Error: Browser closed.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
=================================================================================== 1 error in 9.37s ====================================================================================


@Gopala7721 Gopala7721 changed the title browser closed automatically while running python playwright script: browser closed automatically while running python playwright script. even we cannot launch single page Aug 5, 2022
@mxschmitt
Copy link
Member

Could you provide us your docker-compose_linux.yml and Dockerfile which you are using?

So your host OS is macOS 12.4, could you confirm that?

Are you using an intel mac or arm/m1 mac?

@Gopala7721
Copy link
Author

yes it is :
CUPS Version: CUPS/2.3.4 (macOS 12.4; arm64) IPP/2.0

@mxschmitt
Copy link
Member

Could you provide us your docker-compose and Dockerfile?

@Gopala7721
Copy link
Author

Gopala7721 commented Aug 8, 2022

we cannot share actually we work for client project

@mxschmitt
Copy link
Member

Could you try it with the official Docker image instead? https://playwright.dev/docs/docker

Also if you are not using it, you need to manually install dependencies: https://playwright.dev/docs/cli#install-browsers

playwright install --with-deps aka. python -m playwright install --with-deps

@Gopala7721
Copy link
Author

dev@ccs-dev:/repo/ws/stash.arubanetworks.com/ccs/authz/tests/ui_test$ palywright install chromium
bash: palywright: command not found
dev@ccs-dev:
/repo/ws/stash.arubanetworks.com/ccs/authz/tests/ui_test$ playwright install chromium
dev@ccs-dev:/repo/ws/stash.arubanetworks.com/ccs/authz/tests/ui_test$ # See command help
dev@ccs-dev:
/repo/ws/stash.arubanetworks.com/ccs/authz/tests/ui_test$ playwright install-deps
Installing Ubuntu dependencies...
Switching to root user to install dependencies...
Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB]
Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB]
Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease
Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB]
Hit:5 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease
Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB]
Fetched 316 kB in 12s (25.3 kB/s)
Reading package lists... Done
Reading package lists... Done
playwright install --with-deps chromium
tried all these steps already did not work

@Gopala7721
Copy link
Author

can i pass headless parameter from the command line. currently iam using this command: poetry run pytest testcases/sample.py --browser chromium

@Gopala7721
Copy link
Author

dev@ccs-dev:/tests/ui_test$ palywright install chromium bash: palywright: command not found dev@ccs-dev:/tests/ui_test$ playwright install chromium dev@ccs-dev:/repo/ws/stash.arubanetworks.com/ccs/authz/tests/ui_test$ # See command help dev@ccs-dev:~tests/ui_test$ playwright install-deps Installing Ubuntu dependencies... Switching to root user to install dependencies... Get:1 https://download.docker.com/linux/ubuntu bionic InRelease [64.4 kB] Get:2 http://security.ubuntu.com/ubuntu bionic-security InRelease [88.7 kB] Hit:3 http://archive.ubuntu.com/ubuntu bionic InRelease Get:4 http://archive.ubuntu.com/ubuntu bionic-updates InRelease [88.7 kB] Hit:5 http://apt.postgresql.org/pub/repos/apt bionic-pgdg InRelease Get:6 http://archive.ubuntu.com/ubuntu bionic-backports InRelease [74.6 kB] Fetched 316 kB in 12s (25.3 kB/s) Reading package lists... Done Reading package lists... Done playwright install --with-deps chromium tried all these steps already did not work

@mxschmitt
Copy link
Member

Seems like this issue is mixing a lot of different requests - what are you trying to accomplish / what is not working? Because its hard to follow.

I see that you are using bionic, which is also very old and gets deprecated soon, could you try using focal or jammy and the official Docker image? There is no need to install the dependencies there: https://playwright.dev/python/docs/docker

@rwoll
Copy link
Member

rwoll commented Aug 11, 2022

Per-above closing as part of triage.

We'd love to be more useful here, but there are currently too many unknown factors for us to do more than guess.

Please try to reproduce your issue with minimal code that you can share with us using the official Docker images (https://playwright.dev/python/docs/docker).

A repro will help ensure we are actually debugging the same issue you are facing and will minimize us guessing. This is especially helpful when there are several layers/pieces involved.

Ideally the repro is a GitHub repository we can clone, download, and run to see the issue ourselves. It should include the commands to run it, too.

Thanks!

@rwoll rwoll closed this as completed Aug 11, 2022
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