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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Add method to retrieve the wsEndpoint of a browser launched with Playwright #1572

Closed
ramsestom opened this issue May 6, 2024 · 2 comments

Comments

@ramsestom
Copy link

馃殌 Feature Request

Could you add a method to retrieve the wsEndpoint of any CDP compatible Browser launched with playwright?
Currently this is only accessible on the browserserver class https://playwright.dev/docs/api/class-browserserver which only exists for node.js (hence not available in the java, python, and .net API)
It would be usefull if the wsEndpoint could be exposed as a property of the CDPSession Class for exemple (as each API langage version has a newBrowserCDPSession method). Or directly as a property of the Browser Class.
This would allow to connect to a browser launched with playwright with any other testing framework supporting the CDP which is currently not feasible (only the reverse is. i.e. connect with playwright over CDP to a browser launched outside of playwright)

Example

No response

Motivation

Currently, if we want to mix different testing frameworks (playwright, selenium, pupeteer,...), playwright can't be used as the first framework used in the pipeline (the one who will launch the browser) as it do not allow to know the CDP wsEndpoint of browsers launched with it. Hence the browser always have to be launched outside of playwright (by another framework or directly) and playwright attached to it afterward. This increases the risk of launching a browser with args that will not be optimal for playwright and limit the possibilities for easily integrating playwright into a preexisting testing pipeline (for a step by step transition of a complex testing pipeline to full playwright for example)

@mxschmitt
Copy link
Member

Playwright under the hood does not use WebSockets when connecting to a browser, so there is no way of exposing them. If you want to create a remote connection via Playwright's connection protocol (launchServer/connect) (which is different to CDP) we recommend starting a server either with Node.js or via the CLI and then connecting to it.

If you want to get the CDP port, we recommend launching the browser outside of Playwright and then connecting to it via CDP.

@mxschmitt
Copy link
Member

Closing as per above.

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

2 participants