Skip to content

[Question] Is there a way to access the playwright object in dev tools in browsers launched within launch()? #4610

Closed

Description

Hi team,

I'm launching a browser in this way:

with sync_playwright() as playwright:
    browser = playwright.chromium.launch(headless=False)
    ...

In this browser, is there a way to access the playwright object in the Developer Tools Console, similarly to what you can do when launching a browser using open, e.g.,

python -m playwright open http://localhost:3000

and as described in you documentation? I think it could be useful to debug issues, for instance when a selector cannot find the given element because of a recent change and the flow gets stuck, without the need to manually reproduce the page state generated by the Python code after launch.

Alternatively, what could be a good workaround? For instance, I'm wondering if it's possible in the Developer Tools Console to do something similar to

playwright.selector($0)

when debugging in a browser started with launch.

I tried launching the browser with

playwright.chromium.launch(headless=False, env={"PWDEBUG": True})

but even assuming this is the proper way, I get an error—I can give you more details on this, if you want.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions