CDP¶
The CDP module provides access to Chrome DevTools Protocol commands. For full usage examples, see CDP.
Chrome/Edge only
CDP commands are only supported by Chromium-based browsers.
Methods¶
send_command¶
Send a raw CDP command:
result = await client.cdp.send_command(
method="Performance.getMetrics",
params={},
)
# result.result contains the CDP response
get_session¶
Get the CDP session ID for a specific browsing context:
Reference¶
CDPModule ¶
Module for sending CDP commands directly (Chrome-only).
Allows access to Chrome DevTools Protocol APIs that are not yet covered by WebDriver BiDi.
Example
cdp_session = await client.cdp.get_session() result = await client.cdp.send_command("Page.reload", {})
Source code in bidiwave/modules/cdp.py
get_session
async
¶
Gets the current CDP session ID.
Returns:
| Type | Description |
|---|---|
str | None
|
CDP session ID or None if no active session. |
Source code in bidiwave/modules/cdp.py
send_command
async
¶
Sends a CDP command directly to the browser.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
str
|
CDP command name (e.g. "Page.reload", "Network.enable"). |
required |
params
|
dict[str, Any] | None
|
Command parameters. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
CDP command result as dict. |