@@ -4017,13 +4017,41 @@ async def connect_over_cdp(
40174017 A CDP websocket endpoint or http url to connect to. For example `http://localhost:9222/` or
40184018 `ws://127.0.0.1:9222/devtools/browser/387adf4c-243f-4051-a181-46798f4a46f4`.
40194019
4020- Alternatively, a browser channel name such as `chrome` or `msedge` to connect to a browser with remote debugging
4021- enabled in its default user data directory. On Linux, Playwright uses `CHROME_USER_DATA_DIR` when set. Otherwise,
4022- it uses `CHROME_CONFIG_HOME`, then `XDG_CONFIG_HOME`, then `~/.config` to locate that directory.
4020+ Alternatively, a URL that tells which running browser to connect to:
4021+ - `remote-debugging://<channel>` - a browser with remote debugging enabled, for example
4022+ `remote-debugging://msedge`. The optional `userDataDir` parameter is the user data directory of the browser,
4023+ when it is not the default one: `remote-debugging://chrome?userDataDir=/path/to/data`. A bare channel name such
4024+ as `chrome` is the same as `remote-debugging://chrome`.
4025+ - `extension://<channel>/<profile directory>` - the tabs of a browser profile, through the
4026+ [Playwright Extension](https://chromewebstore.google.com/detail/playwright-extension/mmlmfjhmonkocbjadbfplnigmagldckm),
4027+ for example `extension://chrome/Profile 1`. Playwright opens the connect page of the extension in that profile,
4028+ and the user selects the tabs to share. Without the profile directory, Playwright uses the `Default` profile.
4029+ The optional parameters are `userDataDir`, the user data directory of the browser when it is not the default
4030+ one, and `executablePath`, the path to the browser executable when it is not at the standard location:
4031+ `extension://chromium?executablePath=/path/to/chrome&userDataDir=/path/to/data`. Pass the other options of this
4032+ connection in `headers`.
4033+
4034+ The values of `userDataDir` and `executablePath` must be URL-encoded, for example with `encodeURIComponent` or
4035+ `URLSearchParams`. The channel is a browser channel name such as `chrome`, `chrome-beta` or `msedge`. The default
4036+ user data directory of the channel is where the browser keeps its data. On Linux, Playwright uses
4037+ `CHROME_USER_DATA_DIR` when set. Otherwise, it uses `CHROME_CONFIG_HOME`, then `XDG_CONFIG_HOME`, then `~/.config`
4038+ to locate that directory.
40234039 artifacts_dir : Union[pathlib.Path, str, None]
40244040 If specified, browser artifacts (such as traces and downloads) are saved into this directory.
40254041 headers : Union[Dict[str, str], None]
40264042 Additional HTTP headers to be sent with connect request. Optional.
4043+
4044+ When `endpoint_url` is an extension URL such as `extension://chrome`, the headers are not sent. They are the
4045+ options of the connection:
4046+ - `x-playwright-extension-token` - the token of the extension. With the token, the user does not have to approve
4047+ the connection. Without the token, the user must approve the connection before `timeout` expires, so set it to
4048+ a value that gives the user enough time.
4049+ - `x-playwright-extension-client-name` - the name of the client that the extension shows to the user.
4050+ - `x-playwright-extension-tab-group` - pass `false` to keep the tabs out of a tab group.
4051+ - `x-playwright-extension-tab-group-title` - the title of the tab group.
4052+ - `x-playwright-extension-tab-group-color` - the color of the tab group: `green`, `blue`, `purple`, `orange`,
4053+ `pink`, `cyan`, `yellow` or `red`.
4054+ - `x-playwright-extension-background` - pass `true` to keep the tabs from becoming active.
40274055 is_local : Union[bool, None]
40284056 Tells Playwright that it runs on the same host as the CDP server. It will enable certain optimizations that rely
40294057 upon the file system being the same between Playwright and the Browser.
0 commit comments