Chrome DevTools Protocol transport layer for browser automation
| Tier | infrastructure |
| Role | unclassified (baselined) |
| Path | crates/infrastructure/browser-cdp |
| Edition | 2021 |
| Targets | ab_test, chatgpt_debug, chatgpt_dom, check_chatgpt, debug_sw, dump_cookies, find_text, forge_alt_text_suggestion_shot, forge_alt_text_ui_verify, forge_featured_thumb_verify, forge_logout_audit_e2e, forge_logs_verify, forge_media_upload_diag, forge_media_upload_e2e, forge_page_create_e2e, forge_settings_verify, navigate, sw_console, test_extension, test_extension_wasm, test_wasm_sw, wasm_scan_all, infrastructure_browser_cdp, chrome_integration, mock_tests |
| Public items | 138 across 12 modules |
| Tests | 112 |
What it is for
This crate does not document itself. No //! block on its entry point. The facts below are complete; the reason this crate exists is not written down anywhere, and belongs in src/lib.rs rather than here.
Capabilities
BoxModel
_No module-level documentation is present in the source._
| Item |
|---|
pub struct BoxModel |
DescribeNode
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DescribeNode |
DescribeNode :: fn params(& self) -> Value |
DescribeNodeResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DescribeNodeResponse |
GetBoxModel
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetBoxModel |
GetBoxModel :: fn params(& self) -> Value |
GetBoxModelResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetBoxModelResponse |
GetDocument
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetDocument |
GetDocument :: fn params(& self) -> Value |
GetDocumentResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetDocumentResponse |
Node
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Node |
QuerySelector
_No module-level documentation is present in the source._
| Item |
|---|
pub struct QuerySelector |
QuerySelector :: fn params(& self) -> Value |
QuerySelectorAll
_No module-level documentation is present in the source._
| Item |
|---|
pub struct QuerySelectorAll |
QuerySelectorAll :: fn params(& self) -> Value |
QuerySelectorAllResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct QuerySelectorAllResponse |
QuerySelectorResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct QuerySelectorResponse |
ResolveNode
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ResolveNode |
ResolveNode :: fn params(& self) -> Value |
ResolveNodeResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ResolveNodeResponse |
SetFileInputFiles
_No module-level documentation is present in the source._
| Item |
|---|
pub struct SetFileInputFiles |
SetFileInputFiles :: fn params(& self) -> Value |
SetFileInputFilesResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct SetFileInputFilesResponse |
DispatchKeyEvent
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DispatchKeyEvent |
DispatchKeyEvent :: fn params(& self) -> Value |
DispatchKeyEventResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DispatchKeyEventResponse |
DispatchMouseEvent
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DispatchMouseEvent |
DispatchMouseEvent :: fn params(& self) -> Value |
DispatchMouseEventResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DispatchMouseEventResponse |
InsertText
_No module-level documentation is present in the source._
| Item |
|---|
pub struct InsertText |
InsertText :: fn params(& self) -> Value |
InsertTextResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct InsertTextResponse |
KeyEventType
_No module-level documentation is present in the source._
| Item |
|---|
pub enum KeyEventType |
MouseButton
_No module-level documentation is present in the source._
| Item |
|---|
pub enum MouseButton |
MouseEventType
_No module-level documentation is present in the source._
| Item |
|---|
pub enum MouseEventType |
Disable
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Disable |
Disable :: fn params(& self) -> Value |
DisableResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DisableResponse |
Enable
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Enable |
Enable :: fn params(& self) -> Value |
EnableResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct EnableResponse |
GetResponseBody
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetResponseBody |
GetResponseBody :: fn params(& self) -> Value |
GetResponseBodyResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetResponseBodyResponse |
LoadingFailed
_No module-level documentation is present in the source._
| Item |
|---|
pub struct LoadingFailed |
LoadingFinished
_No module-level documentation is present in the source._
| Item |
|---|
pub struct LoadingFinished |
RequestData
_No module-level documentation is present in the source._
| Item |
|---|
pub struct RequestData |
RequestWillBeSent
_No module-level documentation is present in the source._
| Item |
|---|
pub struct RequestWillBeSent |
ResponseData
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ResponseData |
ResponseReceived
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ResponseReceived |
BringToFront
_No module-level documentation is present in the source._
| Item |
|---|
pub struct BringToFront |
BringToFront :: fn params(& self) -> Value |
BringToFrontResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct BringToFrontResponse |
CaptureScreenshot
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CaptureScreenshot |
CaptureScreenshot :: fn params(& self) -> Value |
CaptureScreenshotResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CaptureScreenshotResponse |
Enable
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Enable |
Enable :: fn params(& self) -> Value |
EnableResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct EnableResponse |
Navigate
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Navigate |
Navigate :: fn params(& self) -> Value |
NavigateResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct NavigateResponse |
ScreenshotFormat
_No module-level documentation is present in the source._
| Item |
|---|
pub enum ScreenshotFormat |
CallFunctionOn
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CallFunctionOn |
CallFunctionOn :: fn params(& self) -> Value |
CallFunctionOnResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CallFunctionOnResponse |
Enable
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Enable |
Enable :: fn params(& self) -> Value |
EnableResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct EnableResponse |
Evaluate
_No module-level documentation is present in the source._
| Item |
|---|
pub struct Evaluate |
Evaluate :: fn params(& self) -> Value |
EvaluateResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct EvaluateResponse |
ExceptionDetails
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ExceptionDetails |
RemoteObject
_No module-level documentation is present in the source._
| Item |
|---|
pub struct RemoteObject |
CdpCookie
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CdpCookie |
ClearCookies
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ClearCookies |
ClearCookies :: fn params(& self) -> Value |
ClearCookiesResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct ClearCookiesResponse |
DeleteCookies
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DeleteCookies |
DeleteCookies :: fn params(& self) -> Value |
DeleteCookiesResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DeleteCookiesResponse |
GetCookies
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetCookies |
GetCookies :: fn params(& self) -> Value |
GetCookiesResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct GetCookiesResponse |
AttachToTarget
_No module-level documentation is present in the source._
| Item |
|---|
pub struct AttachToTarget |
AttachToTarget :: fn params(& self) -> Value |
AttachToTargetResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct AttachToTargetResponse |
DetachFromTarget
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DetachFromTarget |
DetachFromTarget :: fn params(& self) -> Value |
DetachFromTargetResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct DetachFromTargetResponse |
SetAutoAttach
_No module-level documentation is present in the source._
| Item |
|---|
pub struct SetAutoAttach |
SetAutoAttach :: fn params(& self) -> Value |
SetAutoAttachResponse
_No module-level documentation is present in the source._
| Item |
|---|
pub struct SetAutoAttachResponse |
TargetCreated
_No module-level documentation is present in the source._
| Item |
|---|
pub struct TargetCreated |
TargetDestroyed
_No module-level documentation is present in the source._
| Item |
|---|
pub struct TargetDestroyed |
TargetInfoEvent
_No module-level documentation is present in the source._
| Item |
|---|
pub struct TargetInfoEvent |
endpoint (other)
_No module-level documentation is present in the source._
| Item |
|---|
pub const DEFAULT_PORT: u16 |
BrowserEndpoint
_No module-level documentation is present in the source._
| Item |
|---|
pub struct BrowserEndpoint |
BrowserEndpoint :: fn connect(base_url : & str) -> Result <Self, CdpError> |
BrowserEndpoint :: fn connect_or_launch(port : u16) -> Result <(Self, Option <Child>), CdpError> |
BrowserEndpoint :: fn version(& self) -> Result <BrowserVersion, CdpError> |
BrowserEndpoint :: fn list_targets(& self) -> Result <Vec <TargetInfo>, CdpError> |
BrowserEndpoint :: fn find_target <F>(& self, predicate : F) -> Result <Option <TargetInfo>, CdpError> where F : Fn(& TargetInfo) -> bool, |
BrowserEndpoint :: fn find_targets <F>(& self, predicate : F) -> Result <Vec <TargetInfo>, CdpError> where F : Fn(& TargetInfo) -> bool, |
BrowserEndpoint :: fn open_session(& self, target : & TargetInfo) -> Result <CdpSession, CdpError> |
CdpError
_No module-level documentation is present in the source._
| Item |
|---|
pub enum CdpError |
TargetError
_No module-level documentation is present in the source._
| Item |
|---|
pub enum TargetError |
TransportError
_No module-level documentation is present in the source._
| Item |
|---|
pub enum TransportError |
CdpSession:CdpSession
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CdpSession |
CdpSession:close
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn close(mut self) -> Result <(), CdpError> |
CdpSession:connect
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn connect(ws_url : & str) -> Result <Self, CdpError> |
CdpSession:drop
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn drop(& mut self) |
CdpSession:execute
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn execute <C : CdpCommand>(& self, cmd : C) -> Result <C::Response, CdpError> |
CdpSession :: fn execute_with_timeout <C : CdpCommand>(& self, cmd : C, timeout : Duration,) -> Result <C::Response, CdpError> |
CdpSession :: fn execute_raw(& self, method : & str, params : Value) -> Result <Value, CdpError> |
CdpSession :: fn execute_raw_with_timeout(& self, method : & str, params : Value, timeout : Duration,) -> Result <Value, CdpError> |
CdpSession:fmt
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
CdpSession:next
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn next_event(& self) -> Result <CdpEvent, CdpError> |
CdpSession :: fn next_event_timeout(& self, timeout : Duration) -> Result <CdpEvent, CdpError> |
CdpSession:subscribe
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn subscribe(& self, domains : & EventDomain, buffer_size : usize, overflow_policy : OverflowPolicy,) -> Receiver <CdpEvent> |
CdpSession :: fn subscribe_all(& self, buffer_size : usize, overflow_policy : OverflowPolicy,) -> Receiver <CdpEvent> |
CdpSession:try
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn try_next_event(& self) -> Result <Option <CdpEvent>, CdpError> |
CdpSession:wait
_No module-level documentation is present in the source._
| Item |
|---|
CdpSession :: fn wait_for_event <F>(& self, predicate : F, timeout : Duration) -> Result <CdpEvent, CdpError> where F : Fn(& CdpEvent) -> bool, |
BrowserVersion
_No module-level documentation is present in the source._
| Item |
|---|
pub struct BrowserVersion |
CdpCommand
_No module-level documentation is present in the source._
| Item |
|---|
pub trait CdpCommand |
CdpEvent
_No module-level documentation is present in the source._
| Item |
|---|
pub struct CdpEvent |
CdpEvent :: fn domain(& self) -> EventDomain |
EventDomain
_No module-level documentation is present in the source._
| Item |
|---|
pub enum EventDomain |
EventDomain :: fn from_method(method : & str) -> Self |
EventDomain :: fn is_telemetry(& self) -> bool |
OverflowPolicy
_No module-level documentation is present in the source._
| Item |
|---|
pub enum OverflowPolicy |
RequestId
_No module-level documentation is present in the source._
| Item |
|---|
pub struct RequestId |
RequestId :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result |
SessionId
_No module-level documentation is present in the source._
| Item |
|---|
pub struct SessionId |
SessionId :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result |
TargetId
_No module-level documentation is present in the source._
| Item |
|---|
pub struct TargetId |
TargetId :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result |
TargetInfo
_No module-level documentation is present in the source._
| Item |
|---|
pub struct TargetInfo |
How to use it
From `examples/ab_test.rs`:
use infrastructure_browser_cdp::commands::runtime;
use infrastructure_browser_cdp::{BrowserEndpoint, DEFAULT_PORT};
fn main() {
let ep = BrowserEndpoint::connect(&format!("http://localhost:{}", DEFAULT_PORT)).unwrap();
let page_target = ep
.find_target(|t| t.url.contains("nytimes.com") && t.target_type == "page")
.unwrap()
.expect("No NYTimes tab — navigate there first");
let _page_tab_id = page_target.id.clone();
println!("=== A/B TEST: CDP vs WASM Extension ===\n");
println!("Target: {}\n", page_target.url);
println!("--- METHOD A: WASM Extension ---");
let sw_target = ep
From `examples/chatgpt_debug.rs`:
use infrastructure_browser_cdp::commands::runtime;
use infrastructure_browser_cdp::{BrowserEndpoint, DEFAULT_PORT};
fn main() {
let ep = BrowserEndpoint::connect(&format!("http://localhost:{}", DEFAULT_PORT)).unwrap();
let t = ep
.find_target(|t| t.url.contains("chatgpt.com") && t.websocket_url.is_some())
.unwrap()
.expect("No ChatGPT tab");
println!("Tab: {}", t.url);
let s = ep.open_session(&t).unwrap();
let js = r#"JSON.stringify({
editor: !!document.querySelector('#prompt-textarea'),
editorTag: document.querySelector('#prompt-textarea')?.tagName,
editorType: document.querySelector('#prompt-textarea')?.type,
editorContentEditable: document.querySelector('#prompt-textarea')?.contentEditable,
Module structure
infrastructure_browser_cdp
commandscommands::domcommands::inputcommands::networkcommands::pagecommands::runtimecommands::storagecommands::targetendpointerrorsessiontypes
flowchart TD n_infrastructure_browser_cdp["infrastructure_browser_cdp"] n_infrastructure_browser_cdp --> n_commands["commands"] n_commands --> n_commands__dom["dom"] n_commands --> n_commands__input["input"] n_commands --> n_commands__network["network"] n_commands --> n_commands__page["page"] n_commands --> n_commands__runtime["runtime"] n_commands --> n_commands__storage["storage"] n_commands --> n_commands__target["target"] n_infrastructure_browser_cdp --> n_endpoint["endpoint"] n_infrastructure_browser_cdp --> n_error["error"] n_infrastructure_browser_cdp --> n_session["session"] n_infrastructure_browser_cdp --> n_types["types"]
Public surface
`commands::dom`
| Item | What it is |
|---|---|
pub struct GetDocument | Get the root DOM node. |
GetDocument :: fn params(& self) -> Value | — |
pub struct GetDocumentResponse | — |
pub struct Node | — |
pub struct QuerySelector | Query a single element by CSS selector. |
QuerySelector :: fn params(& self) -> Value | — |
pub struct QuerySelectorResponse | — |
pub struct QuerySelectorAll | Query all elements matching a CSS selector. |
QuerySelectorAll :: fn params(& self) -> Value | — |
pub struct QuerySelectorAllResponse | — |
pub struct DescribeNode | Describe a node in detail. |
DescribeNode :: fn params(& self) -> Value | — |
pub struct DescribeNodeResponse | — |
pub struct ResolveNode | Resolve a DOM node to a JavaScript object. |
ResolveNode :: fn params(& self) -> Value | — |
pub struct ResolveNodeResponse | — |
pub struct GetBoxModel | Get the box model (border/padding/content quads) for a node |
GetBoxModel :: fn params(& self) -> Value | — |
pub struct GetBoxModelResponse | — |
pub struct SetFileInputFiles | Set the files selected on an <input type=file> node — the trusted equivalent of a user picking files in the native dialog |
SetFileInputFiles :: fn params(& self) -> Value | — |
pub struct SetFileInputFilesResponse | — |
pub struct BoxModel | A node's box model |
`commands::input`
| Item | What it is |
|---|---|
pub enum KeyEventType | Key event type for dispatchKeyEvent. |
pub struct DispatchKeyEvent | Dispatch a key event to the page. |
DispatchKeyEvent :: fn params(& self) -> Value | — |
pub struct DispatchKeyEventResponse | — |
pub struct InsertText | Insert text as if typed (Input.insertText) |
InsertText :: fn params(& self) -> Value | — |
pub struct InsertTextResponse | — |
pub enum MouseEventType | Mouse event type for dispatchMouseEvent. |
pub enum MouseButton | Mouse button. |
pub struct DispatchMouseEvent | Dispatch a mouse event to the page. |
DispatchMouseEvent :: fn params(& self) -> Value | — |
pub struct DispatchMouseEventResponse | — |
`commands::network`
| Item | What it is |
|---|---|
pub struct Enable | Enable network event collection. |
Enable :: fn params(& self) -> Value | — |
pub struct EnableResponse | — |
pub struct Disable | Disable network event collection. |
Disable :: fn params(& self) -> Value | — |
pub struct DisableResponse | — |
pub struct GetResponseBody | Get response body for a given request ID. |
GetResponseBody :: fn params(& self) -> Value | — |
pub struct GetResponseBodyResponse | — |
pub struct RequestWillBeSent | Fired when a request is about to be sent. |
pub struct RequestData | — |
pub struct ResponseReceived | Fired when a response is received. |
pub struct ResponseData | — |
pub struct LoadingFinished | Fired when loading is finished. |
pub struct LoadingFailed | Fired when loading fails. |
`commands::page`
| Item | What it is |
|---|---|
pub struct Enable | Enable the Page domain events. |
Enable :: fn params(& self) -> Value | — |
pub struct EnableResponse | — |
pub struct Navigate | Navigate to a URL. |
Navigate :: fn params(& self) -> Value | — |
pub struct NavigateResponse | — |
pub struct CaptureScreenshot | Capture a screenshot of the page. |
pub enum ScreenshotFormat | — |
CaptureScreenshot :: fn params(& self) -> Value | — |
pub struct CaptureScreenshotResponse | — |
pub struct BringToFront | Bring the page to front (activate the tab). |
BringToFront :: fn params(& self) -> Value | — |
pub struct BringToFrontResponse | — |
`commands::runtime`
| Item | What it is |
|---|---|
pub struct Enable | Enable the Runtime domain (required for evaluate). |
Enable :: fn params(& self) -> Value | — |
pub struct EnableResponse | — |
pub struct Evaluate | Evaluate a JavaScript expression in the global context. |
Evaluate :: fn params(& self) -> Value | — |
pub struct EvaluateResponse | — |
pub struct RemoteObject | — |
pub struct ExceptionDetails | — |
pub struct CallFunctionOn | Call a function on a specific remote object. |
CallFunctionOn :: fn params(& self) -> Value | — |
pub struct CallFunctionOnResponse | — |
`commands::storage`
| Item | What it is |
|---|---|
pub struct GetCookies | Get all cookies from the browser's cookie store |
GetCookies :: fn params(& self) -> Value | — |
pub struct GetCookiesResponse | — |
pub struct CdpCookie | Full cookie record as returned by CDP. |
pub struct DeleteCookies | Clear specific cookies. |
DeleteCookies :: fn params(& self) -> Value | — |
pub struct DeleteCookiesResponse | — |
pub struct ClearCookies | Clear all browser cookies. |
ClearCookies :: fn params(& self) -> Value | — |
pub struct ClearCookiesResponse | — |
`commands::target`
| Item | What it is |
|---|---|
pub struct AttachToTarget | Attach to a target. |
AttachToTarget :: fn params(& self) -> Value | — |
pub struct AttachToTargetResponse | — |
pub struct DetachFromTarget | Detach from a target. |
DetachFromTarget :: fn params(& self) -> Value | — |
pub struct DetachFromTargetResponse | — |
pub struct SetAutoAttach | Set auto-attach for new targets. |
SetAutoAttach :: fn params(& self) -> Value | — |
pub struct SetAutoAttachResponse | — |
pub struct TargetCreated | Fired when a target is created. |
pub struct TargetDestroyed | Fired when a target is destroyed. |
pub struct TargetInfoEvent | Target info within events. |
`endpoint`
| Item | What it is |
|---|---|
pub const DEFAULT_PORT: u16 | Default Chrome debugging port. |
pub struct BrowserEndpoint | Chrome debugging endpoint for HTTP-based target discovery. |
BrowserEndpoint :: fn connect(base_url : & str) -> Result <Self, CdpError> | Connect to a Chrome debugging endpoint |
BrowserEndpoint :: fn connect_or_launch(port : u16) -> Result <(Self, Option <Child>), CdpError> | Connect to Chrome on the default port, or launch it if not running |
BrowserEndpoint :: fn version(& self) -> Result <BrowserVersion, CdpError> | Get browser version information. |
BrowserEndpoint :: fn list_targets(& self) -> Result <Vec <TargetInfo>, CdpError> | List all debuggable targets (tabs, workers, etc.) |
BrowserEndpoint :: fn find_target <F>(& self, predicate : F) -> Result <Option <TargetInfo>, CdpError> where F : Fn(& TargetInfo) -> bool, | Find the first target matching a predicate. |
BrowserEndpoint :: fn find_targets <F>(& self, predicate : F) -> Result <Vec <TargetInfo>, CdpError> where F : Fn(& TargetInfo) -> bool, | Find all targets matching a predicate. |
BrowserEndpoint :: fn open_session(& self, target : & TargetInfo) -> Result <CdpSession, CdpError> | Open a CDP session to the given target over WebSocket. |
`error`
| Item | What it is |
|---|---|
pub enum CdpError | — |
pub enum TransportError | — |
pub enum TargetError | — |
`session`
| Item | What it is |
|---|---|
pub struct CdpSession | Persistent WebSocket session to a Chrome DevTools Protocol target |
CdpSession :: fn connect(ws_url : & str) -> Result <Self, CdpError> | Connect to a Chrome target via WebSocket URL. |
CdpSession :: fn execute <C : CdpCommand>(& self, cmd : C) -> Result <C::Response, CdpError> | Execute a typed CDP command and return the deserialized response. |
CdpSession :: fn execute_with_timeout <C : CdpCommand>(& self, cmd : C, timeout : Duration,) -> Result <C::Response, CdpError> | Execute a typed CDP command with a custom timeout. |
CdpSession :: fn execute_raw(& self, method : & str, params : Value) -> Result <Value, CdpError> | Execute a raw CDP command by method name and params. |
CdpSession :: fn execute_raw_with_timeout(& self, method : & str, params : Value, timeout : Duration,) -> Result <Value, CdpError> | Execute a raw CDP command with a custom timeout. |
CdpSession :: fn next_event(& self) -> Result <CdpEvent, CdpError> | Get the next control-plane event, blocking until one arrives or timeout. |
CdpSession :: fn next_event_timeout(& self, timeout : Duration) -> Result <CdpEvent, CdpError> | Get the next control-plane event with timeout. |
CdpSession :: fn try_next_event(& self) -> Result <Option <CdpEvent>, CdpError> | Get the next control-plane event without blocking. |
CdpSession :: fn wait_for_event <F>(& self, predicate : F, timeout : Duration) -> Result <CdpEvent, CdpError> where F : Fn(& CdpEvent) -> bool, | Wait for a specific control-plane event matching a predicate, with timeout. |
CdpSession :: fn subscribe(& self, domains : & EventDomain, buffer_size : usize, overflow_policy : OverflowPolicy,) -> Receiver <CdpEvent> | Subscribe to events from specific domains |
CdpSession :: fn subscribe_all(& self, buffer_size : usize, overflow_policy : OverflowPolicy,) -> Receiver <CdpEvent> | Subscribe to ALL events (every domain) |
CdpSession :: fn close(mut self) -> Result <(), CdpError> | Close the session, shutting down the reader thread. |
CdpSession :: fn drop(& mut self) | — |
CdpSession :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
`types`
| Item | What it is |
|---|---|
pub struct TargetId | Unique identifier for a browser target (tab, worker, etc.) |
TargetId :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result | — |
pub struct SessionId | Session identifier for an attached CDP session |
SessionId :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result | — |
pub struct RequestId | Auto-incrementing request ID for correlating CDP responses |
RequestId :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result | — |
pub struct BrowserVersion | Browser version information from /json/version |
pub struct TargetInfo | Description of a debuggable browser target |
pub trait CdpCommand | Trait for typed CDP commands |
pub struct CdpEvent | CDP event received from the browser |
CdpEvent :: fn domain(& self) -> EventDomain | Extract the CDP domain from the method name (e.g., "Network" from "Network.requestWillBeSent"). |
pub enum EventDomain | CDP event domain for routing events to the right queue. |
EventDomain :: fn from_method(method : & str) -> Self | Parse the domain from a CDP method string like "Network.requestWillBeSent". |
EventDomain :: fn is_telemetry(& self) -> bool | Whether this domain is high-volume telemetry (routed to subscribers, not control queue). |
pub enum OverflowPolicy | Policy for handling subscriber channel overflow. |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
CdpError | error::CdpError |
CdpSession | session::CdpSession |
{BrowserEndpoint,DEFAULT_PORT} | endpoint::{BrowserEndpoint,DEFAULT_PORT} |
{BrowserVersion,CdpCommand,CdpEvent,EventDomain,OverflowPolicy,RequestId,SessionId,TargetId,TargetInfo,} | types::{BrowserVersion,CdpCommand,CdpEvent,EventDomain,OverflowPolicy,RequestId,SessionId,TargetId,TargetInfo,} |
Boundary
Depends on no other workspace tier.
Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).
_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._
Where it sits
| Tier (ontology) | infrastructure |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/infrastructure/browser-cdp |
| Vocabulary in force (lexicon) | current |
Dependencies
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
thiserror | ^2 | — | no | always |
tracing | ^0.1 | — | no | always |
tungstenite | ^0.26 | — | no | always |
ureq | ^3 | — | no | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tungstenite | ^0.26 | — | no | always |
Build. None.
Depended on by. 11 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_browser_cdp["application-browser-cdp"] -->|uses| SELF n_infrastructure_acquire["infrastructure-acquire"] -->|uses| SELF n_infrastructure_browser_automation["infrastructure-browser-automation"] -->|uses| SELF n_infrastructure_chatgpt_cdp["infrastructure-chatgpt-cdp"] -->|uses| SELF n_infrastructure_gemini_cdp["infrastructure-gemini-cdp"] -->|uses| SELF n_infrastructure_whatsapp_cdp["infrastructure-whatsapp-cdp"] -->|uses| SELF n_operations_e2e_harness["operations-e2e-harness"] -->|uses| SELF n_operations_privacy_scan_runner["operations-privacy-scan-runner"] -->|uses| SELF n_platform_disclosure_lab["platform-disclosure-lab"] -->|uses| SELF n_tools_browser_test["tools-browser-test"] -->|uses| SELF n_tools_sighting_ingest["tools-sighting-ingest"] -->|uses| SELF SELF["infrastructure-browser-cdp"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
| Feature | Enables | On by default |
|---|---|---|
wasm-scan-example | — | no |
flowchart LR n_wasm_scan_example["wasm-scan-example"]
Targets
Error model
| Error type | Named by |
|---|---|
CdpError | declared, no public signature returns it |
TargetError | declared, no public signature returns it |
TransportError | declared, no public signature returns it |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | none detected |
| async runtime | none detected |
| database access | none detected |
| network I/O | none detected |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
CHROME_PATH | src/endpoint.rs |
Related capabilities
11 workspace crates depend on this one: application-browser-cdp, infrastructure-acquire, infrastructure-browser-automation, infrastructure-chatgpt-cdp, infrastructure-gemini-cdp, infrastructure-whatsapp-cdp, operations-e2e-harness, operations-privacy-scan-runner, platform-disclosure-lab, tools-browser-test, tools-sighting-ingest.
Verification
| Kind | Count |
|---|---|
| Unit tests | 81 |
| Integration tests | 31 |
| Examples | 22 |
| Doctests | 0 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
commands::dom | 16 | 4 | 7 |
commands::input | 9 | 0 | 17 |
commands::network | 12 | 1 | 1 |
commands::page | 9 | 2 | 8 |
commands::runtime | 8 | 2 | 10 |
commands::storage | 7 | 1 | 1 |
commands::target | 9 | 0 | 0 |
endpoint | 2 | 2 | 11 |
error | 3 | 0 | 5 |
session | 1 | 1 | 10 |
types | 9 | 0 | 3 |
What the tests establish, by name:
capture_screenshot—tests/chrome_integration.rsconnect_or_launch_works—tests/chrome_integration.rsconnect_to_running_chrome—tests/chrome_integration.rsdom_query_on_example_com—tests/chrome_integration.rsevaluate_js_in_first_page_tab—tests/chrome_integration.rsevent_demuxing_with_page_enable—tests/chrome_integration.rslist_targets_returns_at_least_one—tests/chrome_integration.rsnavigate_to_example_com_and_read_title—tests/chrome_integration.rscontrol_events_go_to_both_queue_and_subscriber—tests/mock_tests.rsend_to_end_endpoint_to_session_to_evaluate—tests/mock_tests.rsendpoint_connect_and_list_targets—tests/mock_tests.rsendpoint_connect_fails_for_bad_url—tests/mock_tests.rsendpoint_find_target_by_url—tests/mock_tests.rsendpoint_find_target_returns_none_for_no_match—tests/mock_tests.rsendpoint_find_targets_returns_multiple—tests/mock_tests.rsendpoint_version—tests/mock_tests.rsexecute_with_timeout_works—tests/mock_tests.rssession_close_succeeds—tests/mock_tests.rssession_connect_fails_for_bad_url—tests/mock_tests.rssession_demuxes_events_from_responses—tests/mock_tests.rssession_execute_capture_screenshot—tests/mock_tests.rssession_execute_dom_get_document—tests/mock_tests.rssession_execute_dom_query_selector—tests/mock_tests.rssession_execute_page_navigate—tests/mock_tests.rssession_execute_raw—tests/mock_tests.rssession_execute_runtime_evaluate—tests/mock_tests.rssession_handles_protocol_error—tests/mock_tests.rssession_multiple_sequential_commands—tests/mock_tests.rssession_wait_for_event_with_predicate—tests/mock_tests.rssubscriber_receives_all_events—tests/mock_tests.rs- _… 82 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 72 | 138 |
Public modules with a //! block | 0 | 12 |
pie showData
title Public items with rustdoc
"Documented" : 72
"No rustdoc detected" : 66
Metrics
| Metric | Value |
|---|---|
| Rust source files | 13 |
| Source lines | 2700 |
| Code lines | 2196 |
| Public API items | 138 |
| Public modules | 12 |
| Tests | 112 |
| Examples | 22 |
| Cargo features | 1 |
| Direct runtime dependencies | 6 |
| Workspace reverse dependencies | 11 |
pie showData
title Public API by kind
"constant" : 1
"enum" : 9
"method" : 53
"struct" : 74
"trait" : 1
pie showData
title Rust source composition
"Code" : 2196
"Blank or comment" : 504
Generation
Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.