Skip to content

[Bug]: Chromium Playwright >= 1.49.0 stuck at loading pages #2820

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

Open
pandel opened this issue Apr 17, 2025 · 7 comments
Open

[Bug]: Chromium Playwright >= 1.49.0 stuck at loading pages #2820

pandel opened this issue Apr 17, 2025 · 7 comments

Comments

@pandel
Copy link

pandel commented Apr 17, 2025

Version

Works: up to 1.48.0, does not work: anything newer

Steps to reproduce

I am capturing Grafana panels via Playwright Chromium in headless mode and noticed, that beginning with Playwright>=1.49.0, which uses the newest Chromium tech (microsoft/playwright#33566), I am no longer able to acquire Grafana's login page or anything else.

Expected behavior

Headless browser loads Grafana pages and takes screenshot.

Did this work before?
Yes, up to Playwright version 1.48.0 flawlessly.

Actual behavior

Use my test script. With >=1.49 it will stop at "Enter username".

Additional context

How do we reproduce it?

pip install playwright==1.49.0
playwright install-deps && playwright install chromium
Use added Python file to test: python playwright_browser_test.py -u -p -url
i.e.: python playwright_browser_test.py -u admin -p admin -url http://my.instance.url:3000

With Playwright<1.49.0 the script will go through a complete login process and return with the headless browser closed. With >=1.49 it will stop at "Enter username".

playwright_browser_test.py.txt

I did also check with the people from Grafana and it seems they ran into the same issue: grafana/grafana#103483

Environment

Grafana: 11.6.0
OS: Debian 12
Browser: Chromium headless v131 (coming via playwright install chromium)

Grafana platform?
Docker
@ltsuda
Copy link

ltsuda commented Apr 17, 2025

Please, could you try using the new headless mode? https://playwright.dev/python/docs/browsers#chromium-new-headless-mode

browser = await playwright.chromium.launch(headless=True, channel="chromium")

Optionally, install with this --no-shell to not download the old chromium headless shell.

playwright install --no-shell chromium (--with-deps)

@pandel
Copy link
Author

pandel commented Apr 18, 2025

@ltsuda Did you ever take a look at my test script that I provided? I did already!

browser = await playwright.chromium.launch(headless=True)

And that is exactly the problem. Don't know why I should test things which lead exactly to my bug report...

@aspiringVegetarian
Copy link

@pandel

browser = await playwright.chromium.launch(headless=True)

is not the same as

browser = await playwright.chromium.launch(headless=True, channel="chromium")

I was hitting this same condition and using the "chromium" channel fixed the issue.

@pandel
Copy link
Author

pandel commented Apr 20, 2025

@aspiringVegetarian OH WOW! I did read everything about browser selection again in the Playwright Docs but did absolutely not recognize this to be something different. And as I only installed "chromium" via playwright install chromium I would never have expected that one has to address this on top of that!

MANY MANY THANKS! And my apologies for being a bit rude. The whole problem was sooo frustrating at times! There should be definitely a hint or something in the docs that people can avoid potential problems using this channel= parameter.

@mxschmitt
Copy link
Member

This still looks like a bug to me. headless: true should behave the same as channel: 'chromium'. Happy to investigate further on our side, esp. if it was working in previous versions.

I tried to repro but for me it is always stuck at Wait for selector .page-dashboard which I consider it works as expected?

I created a Grafana instance via this: https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ - did docker run and created a password and nothing else. Is more configuration needed on Grafana side? Since I had the impression that it stopped at Enter username.

@pandel
Copy link
Author

pandel commented Apr 21, 2025

@mxschmitt If it is stuck at Wait for selector .page-dashboard, then the page has loaded, Playwright was able to enter the password but couldn't find the CSS selector, which is not that big deal.

If you chose to use my testscript, then simply replace the line

await page.wait_for_selector('.page-dashboard', timeout=30000)

with

selector = "data-testid navigation mega-menu"
await page.locator(f'[data-testid^="{selector}"]').wait_for(timeout=30000)

You can find more about Grafana standard page element selectors here, if that does not work with your Grafana version:
https://github.com/grafana/grafana/tree/main/packages/grafana-e2e-selectors/src/selectors

@aspiringVegetarian
Copy link

This still looks like a bug to me. headless: true should behave the same as channel: 'chromium'. Happy to investigate further on our side, esp. if it was working in previous versions.

I tried to repro but for me it is always stuck at Wait for selector .page-dashboard which I consider it works as expected?

I created a Grafana instance via this: https://grafana.com/docs/grafana/latest/setup-grafana/installation/docker/ - did docker run and created a password and nothing else. Is more configuration needed on Grafana side? Since I had the impression that it stopped at Enter username.

My understanding of the new chromium headless mode is that it is opt-in... https://playwright.dev/python/docs/browsers#chromium-new-headless-mode

So headless: true uses the "old" headless mode - chromium-headless-shell - while headless: true & channel: 'chromium' uses the "new" headless mode?

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

4 participants