Skip to content

Commit 1936cfa

Browse files
authored
chore(docs): clarify connection method via BrowserType.connect (#34560)
1 parent d288fbc commit 1936cfa

File tree

2 files changed

+48
-10
lines changed

2 files changed

+48
-10
lines changed

docs/src/api/class-browsertype.md

+22-2
Original file line numberDiff line numberDiff line change
@@ -87,15 +87,31 @@ class BrowserTypeExamples
8787

8888
## async method: BrowserType.connect
8989
* since: v1.8
90+
* langs: js
9091
- returns: <[Browser]>
9192

92-
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).
93+
This method attaches Playwright to an existing browser instance created via [`method: BrowserType.launchServer`].
94+
95+
:::note
96+
The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
97+
:::
98+
99+
## async method: BrowserType.connect
100+
* since: v1.8
101+
* langs: python, csharp, java
102+
- returns: <[Browser]>
103+
104+
This method attaches Playwright to an existing browser instance created via `BrowserType.launchServer` in Node.js.
105+
106+
:::note
107+
The major and minor version of the Playwright instance that connects needs to match the version of Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
108+
:::
93109

94110
### param: BrowserType.connect.wsEndpoint
95111
* since: v1.10
96112
- `wsEndpoint` <[string]>
97113

98-
A browser websocket endpoint to connect to.
114+
A Playwright browser websocket endpoint to connect to. You obtain this endpoint via [`method: BrowserServer.wsEndpoint`].
99115

100116
### option: BrowserType.connect.headers
101117
* since: v1.11
@@ -152,6 +168,10 @@ The default browser context is accessible via [`method: Browser.contexts`].
152168
Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
153169
:::
154170

171+
:::note
172+
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`].
173+
:::
174+
155175
**Usage**
156176

157177
```js

packages/playwright-core/types/types.d.ts

+26-8
Original file line numberDiff line numberDiff line change
@@ -14554,6 +14554,11 @@ export interface BrowserType<Unused = {}> {
1455414554
*
1455514555
* **NOTE** Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
1455614556
*
14557+
* **NOTE** This connection is significantly lower fidelity than the Playwright protocol connection via
14558+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14559+
* If you are experiencing issues or attempting to use advanced functionality, you probably want to use
14560+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14561+
*
1455714562
* **Usage**
1455814563
*
1455914564
* ```js
@@ -14579,6 +14584,11 @@ export interface BrowserType<Unused = {}> {
1457914584
*
1458014585
* **NOTE** Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
1458114586
*
14587+
* **NOTE** This connection is significantly lower fidelity than the Playwright protocol connection via
14588+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14589+
* If you are experiencing issues or attempting to use advanced functionality, you probably want to use
14590+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14591+
*
1458214592
* **Usage**
1458314593
*
1458414594
* ```js
@@ -14593,10 +14603,14 @@ export interface BrowserType<Unused = {}> {
1459314603
*/
1459414604
connectOverCDP(options: ConnectOverCDPOptions & { wsEndpoint?: string }): Promise<Browser>;
1459514605
/**
14596-
* This method attaches Playwright to an existing browser instance. When connecting to another browser launched via
14597-
* `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is
14598-
* compatible with 1.2.x).
14599-
* @param wsEndpoint A browser websocket endpoint to connect to.
14606+
* This method attaches Playwright to an existing browser instance created via
14607+
* [browserType.launchServer([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-server).
14608+
*
14609+
* **NOTE** The major and minor version of the Playwright instance that connects needs to match the version of
14610+
* Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
14611+
*
14612+
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via
14613+
* [browserServer.wsEndpoint()](https://playwright.dev/docs/api/class-browserserver#browser-server-ws-endpoint).
1460014614
* @param options
1460114615
*/
1460214616
connect(wsEndpoint: string, options?: ConnectOptions): Promise<Browser>;
@@ -14607,10 +14621,14 @@ export interface BrowserType<Unused = {}> {
1460714621
* @deprecated
1460814622
*/
1460914623
/**
14610-
* This method attaches Playwright to an existing browser instance. When connecting to another browser launched via
14611-
* `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is
14612-
* compatible with 1.2.x).
14613-
* @param wsEndpoint A browser websocket endpoint to connect to.
14624+
* This method attaches Playwright to an existing browser instance created via
14625+
* [browserType.launchServer([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-server).
14626+
*
14627+
* **NOTE** The major and minor version of the Playwright instance that connects needs to match the version of
14628+
* Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
14629+
*
14630+
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via
14631+
* [browserServer.wsEndpoint()](https://playwright.dev/docs/api/class-browserserver#browser-server-ws-endpoint).
1461414632
* @param options
1461514633
*/
1461614634
connect(options: ConnectOptions & { wsEndpoint?: string }): Promise<Browser>;

0 commit comments

Comments
 (0)