Skip to content

Commit 13d80f1

Browse files
authored
cherry-pick(#34560): chore(docs): clarify connection method via BrowserType.connect (#34562)
1 parent 159210d commit 13d80f1

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
@@ -14566,6 +14566,11 @@ export interface BrowserType<Unused = {}> {
1456614566
*
1456714567
* **NOTE** Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
1456814568
*
14569+
* **NOTE** This connection is significantly lower fidelity than the Playwright protocol connection via
14570+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14571+
* If you are experiencing issues or attempting to use advanced functionality, you probably want to use
14572+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14573+
*
1456914574
* **Usage**
1457014575
*
1457114576
* ```js
@@ -14591,6 +14596,11 @@ export interface BrowserType<Unused = {}> {
1459114596
*
1459214597
* **NOTE** Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
1459314598
*
14599+
* **NOTE** This connection is significantly lower fidelity than the Playwright protocol connection via
14600+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14601+
* If you are experiencing issues or attempting to use advanced functionality, you probably want to use
14602+
* [browserType.connect(wsEndpoint[, options])](https://playwright.dev/docs/api/class-browsertype#browser-type-connect).
14603+
*
1459414604
* **Usage**
1459514605
*
1459614606
* ```js
@@ -14605,10 +14615,14 @@ export interface BrowserType<Unused = {}> {
1460514615
*/
1460614616
connectOverCDP(options: ConnectOverCDPOptions & { wsEndpoint?: string }): Promise<Browser>;
1460714617
/**
14608-
* This method attaches Playwright to an existing browser instance. When connecting to another browser launched via
14609-
* `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is
14610-
* compatible with 1.2.x).
14611-
* @param wsEndpoint A browser websocket endpoint to connect to.
14618+
* This method attaches Playwright to an existing browser instance created via
14619+
* [browserType.launchServer([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-server).
14620+
*
14621+
* **NOTE** The major and minor version of the Playwright instance that connects needs to match the version of
14622+
* Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
14623+
*
14624+
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via
14625+
* [browserServer.wsEndpoint()](https://playwright.dev/docs/api/class-browserserver#browser-server-ws-endpoint).
1461214626
* @param options
1461314627
*/
1461414628
connect(wsEndpoint: string, options?: ConnectOptions): Promise<Browser>;
@@ -14619,10 +14633,14 @@ export interface BrowserType<Unused = {}> {
1461914633
* @deprecated
1462014634
*/
1462114635
/**
14622-
* This method attaches Playwright to an existing browser instance. When connecting to another browser launched via
14623-
* `BrowserType.launchServer` in Node.js, the major and minor version needs to match the client version (1.2.3 → is
14624-
* compatible with 1.2.x).
14625-
* @param wsEndpoint A browser websocket endpoint to connect to.
14636+
* This method attaches Playwright to an existing browser instance created via
14637+
* [browserType.launchServer([options])](https://playwright.dev/docs/api/class-browsertype#browser-type-launch-server).
14638+
*
14639+
* **NOTE** The major and minor version of the Playwright instance that connects needs to match the version of
14640+
* Playwright that launches the browser (1.2.3 → is compatible with 1.2.x).
14641+
*
14642+
* @param wsEndpoint A Playwright browser websocket endpoint to connect to. You obtain this endpoint via
14643+
* [browserServer.wsEndpoint()](https://playwright.dev/docs/api/class-browserserver#browser-server-ws-endpoint).
1462614644
* @param options
1462714645
*/
1462814646
connect(options: ConnectOptions & { wsEndpoint?: string }): Promise<Browser>;

0 commit comments

Comments
 (0)