chore(docs): clarify connection method via BrowserType.connect

This commit is contained in:
Adam Gastineau 2025-01-30 11:04:08 -08:00
parent 833c729eb0
commit 740f9037e9

View file

@ -87,15 +87,23 @@ class BrowserTypeExamples
## async method: BrowserType.connect ## async method: BrowserType.connect
* since: v1.8 * since: v1.8
* langs: js
- returns: <[Browser]> - returns: <[Browser]>
This method attaches Playwright to an existing browser instance. When connecting to another browser launched via `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is compatible with 1.2.x). This method attaches Playwright to an existing browser instance created via [`method: BrowserType.launchServer`], which can only be run from Node.js. When connecting to another browser, the major and minor version of the Playwright instance you're calling from needs to match the client browser version (1.2.3 → is compatible with 1.2.x).
## async method: BrowserType.connect
* since: v1.8
* langs: python, csharp, java
- returns: <[Browser]>
This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js. When connecting to another browser, the major and minor version of the Playwright instance you're calling from needs to match the client browser version (1.2.3 → is compatible with 1.2.x).
### param: BrowserType.connect.wsEndpoint ### param: BrowserType.connect.wsEndpoint
* since: v1.10 * since: v1.10
- `wsEndpoint` <[string]> - `wsEndpoint` <[string]>
A browser websocket endpoint to connect to. A Playwright browser websocket endpoint to connect to. You obtain this endpoint via [`method: BrowserServer.wsEndpoint`]
### option: BrowserType.connect.headers ### option: BrowserType.connect.headers
* since: v1.11 * since: v1.11
@ -152,6 +160,10 @@ The default browser context is accessible via [`method: Browser.contexts`].
Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers. Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
::: :::
:::note
This connection is significantly lower fidelity than the Playwright protocol connection via [`method: BrowserType.connect`]. If you are experiencing issues or attempting to use advanced functionality, you probably want to use [`method: BrowserType.connect`].
:::
**Usage** **Usage**
```js ```js