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