docs: provide examples for connectOverCDP (#17189)
This commit is contained in:
parent
158408a2af
commit
aad745acab
|
|
@ -136,6 +136,36 @@ 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.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
|
```js
|
||||||
|
const browser = await playwright.chromium.connectOverCDP('http://localhost:9222');
|
||||||
|
const defaultContext = browser.contexts()[0];
|
||||||
|
const page = defaultContext.pages()[0];
|
||||||
|
```
|
||||||
|
|
||||||
|
```java
|
||||||
|
Browser browser = playwright.chromium().connectOverCDP("http://localhost:9222");
|
||||||
|
BrowserContext defaultContext = browser.contexts().get(0);
|
||||||
|
Page page = defaultContext.pages().get(0);
|
||||||
|
```
|
||||||
|
|
||||||
|
```python async
|
||||||
|
browser = await playwright.chromium.connect_over_cdp("http://localhost:9222")
|
||||||
|
default_context = browser.contexts[0]
|
||||||
|
page = default_context.pages[0]
|
||||||
|
```
|
||||||
|
|
||||||
|
```python sync
|
||||||
|
browser = playwright.chromium.connect_over_cdp("http://localhost:9222")
|
||||||
|
default_context = browser.contexts[0]
|
||||||
|
page = default_context.pages[0]
|
||||||
|
```
|
||||||
|
|
||||||
|
```csharp
|
||||||
|
var browser = await playwright.Chromium.ConnectOverCDPAsync("http://localhost:9222");
|
||||||
|
var defaultContext = browser.Contexts[0];
|
||||||
|
var page = defaultContext.Pages[0];
|
||||||
|
```
|
||||||
|
|
||||||
### param: BrowserType.connectOverCDP.endpointURL
|
### param: BrowserType.connectOverCDP.endpointURL
|
||||||
* since: v1.11
|
* since: v1.11
|
||||||
- `endpointURL` <[string]>
|
- `endpointURL` <[string]>
|
||||||
|
|
|
||||||
14
packages/playwright-core/types/types.d.ts
vendored
14
packages/playwright-core/types/types.d.ts
vendored
|
|
@ -10363,6 +10363,13 @@ export interface BrowserType<Unused = {}> {
|
||||||
* [browser.contexts()](https://playwright.dev/docs/api/class-browser#browser-contexts).
|
* [browser.contexts()](https://playwright.dev/docs/api/class-browser#browser-contexts).
|
||||||
*
|
*
|
||||||
* > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
* > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const browser = await playwright.chromium.connectOverCDP('http://localhost:9222');
|
||||||
|
* const defaultContext = browser.contexts()[0];
|
||||||
|
* const page = defaultContext.pages()[0];
|
||||||
|
* ```
|
||||||
|
*
|
||||||
* @param endpointURL A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
|
* @param endpointURL A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
|
|
@ -10378,6 +10385,13 @@ export interface BrowserType<Unused = {}> {
|
||||||
* [browser.contexts()](https://playwright.dev/docs/api/class-browser#browser-contexts).
|
* [browser.contexts()](https://playwright.dev/docs/api/class-browser#browser-contexts).
|
||||||
*
|
*
|
||||||
* > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
* > NOTE: Connecting over the Chrome DevTools Protocol is only supported for Chromium-based browsers.
|
||||||
|
*
|
||||||
|
* ```js
|
||||||
|
* const browser = await playwright.chromium.connectOverCDP('http://localhost:9222');
|
||||||
|
* const defaultContext = browser.contexts()[0];
|
||||||
|
* const page = defaultContext.pages()[0];
|
||||||
|
* ```
|
||||||
|
*
|
||||||
* @param endpointURL A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
|
* @param endpointURL A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
|
||||||
* @param options
|
* @param options
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue