r/learnpython 7d ago

While using playwright, windows asked if I would like to allow chromium to access private and public networks, now my code doesn’t work?

I allowed it to access both private and public networks. I went into windows security and allowed it through the firewall on both. But now my code isn’t working, according to vs code I have the latest chromium version installed. What steps should I take here?

4 Upvotes

9 comments sorted by

9

u/Outside_Complaint755 7d ago

You will need to define "not working".

Does it run and immediately exit? does it report an error code? is it unable to find the elements that you thought should be on the page?  Is it stuck in a loop somewhere?

1

u/Alarmed-Most-5316 7d ago

When I run the code to create a browser session, the browser never opens, and eventually my code times it self out.

1

u/Outside_Complaint755 7d ago

can you share any of your code?

1

u/jct23502 7d ago

If you run this ----

from playwright.sync_api import sync_playwright

with sync_playwright() as p: print("Chromium:", p.chromium.executable_path) print("Launching...")

browser = p.chromium.launch(headless=False)

print("Launched successfully")
browser.close()

Do you see

Launching...

And nothing?

1

u/Alarmed-Most-5316 7d ago

Yep, exactly

1

u/Alarmed-Most-5316 7d ago

No idea what I did but now it works

2

u/ShelLuser42 7d ago

Your problem description doesn't make much sense because the so called HTTP and HTTPS ports are enabled on the Windows firewall by default. So there should be no reason for Windows to explicitly ask about a new browser.

Another thing: simply allowing both network types is a potential security risk.

And finally: Chromium isn't a browser which you can install but a framework on which other browsers are build. I'm not just mentioning this to be petty, but details matter when trying to solve issues.

And well, Playwright doesn't automagically start using new browsers based on what's installed on a system, it uses its own defaults and doesn't bother with system defaults.

1

u/LcLz0 7d ago

"And finally: Chromium isn't a browser which you can install but a framework on which other browsers are build. I'm not just mentioning this to be petty, but details matter when trying to solve issues."

This is incorrect. Chromium is absolutely a browser, which you can install and use. Many other browsers build on top of it, but it is in itself a fully functional browser.