Skip to main content

Module cdp

Module cdp 

Source
Expand description

P10: Chrome DevTools Protocol (CDP) client.

Attach-only. The user runs Chrome with --remote-debugging-port=N; we discover N from the pid’s argv and connect. We never spawn a new Chrome instance — every Chrome life cycle belongs to the user.

§Sync bridge

DesktopBackend stays synchronous. For each browser subcommand we build a fresh tokio::runtime::Builder::new_current_thread() runtime on the CLI thread, block_on the async CDP request, and drop the runtime on the way out. The handler task chromiumoxide returns is spawned on that runtime, so it is also dropped when the runtime is. Chrome is not affected.

§Errors

Every failure funnels into one of:

  • ComputerError::Unsupported("...") — built without --features cdp.
  • ComputerError::CdpUnavailable("...") — Chrome not running with a debug port, or the websocket died.
  • ComputerError::BlockedUrl("...") — the URL is in [browser].blocked_urls in the policy; the request never reaches CDP.
  • ComputerError::InvalidArguments("...") — missing selector/url/script.
  • ComputerError::ElementNotFound("...") — selector find_element came back empty (synthesized from find_element errors where applicable).

Structs§

ActionOptions
Argument set the action helpers receive (the browser subcommands route to it).
AttachOptions
What the CLI passes to [attach] so it can find Chrome.
TabSummary
JSON-friendly tab summary.

Functions§

activate_tab
click
discover_debug_port
Highest-level port discovery. Public so unit tests can stub it.
eval
list_tabs
navigate
parse_debug_port
Parse the argv text for --remote-debugging-port=N (or --remote-debugging-port N).
read_inner_text
type_text
unsupported
Stable error used when the binary is built without --features cdp.