Skip to main content

Crate cdp_driver

Crate cdp_driver 

Source
Expand description

Chrome DevTools Protocol (CDP) client for browser automation.

Connects to a Chrome instance started with --remote-debugging-port and drives it over the CDP WebSocket: navigation, DOM/JS evaluation, screenshots, network interception, cookies, and more.

Two API layers are available:

Enable the blocking feature for a synchronous API ([blocking]) that needs no async runtime from the caller.

§Example

use cdp_driver::{BrowserAgent, BrowserAction, Config};

let agent = BrowserAgent::connect_with_config(&Config::default()).await?;

agent.execute(BrowserAction::Navigate {
    url: "https://example.com".to_string(),
}).await;

Re-exports§

pub use action::BrowserAction;
pub use action_builder::ActionBuilder;
pub use agent::ActionResult;
pub use agent::BrowserAgent;
pub use client::CdpClient;
pub use config::Config;
pub use error::CdpError;
pub use error::Result;
pub use session::CdpSession;
pub use session::SessionEvent;
pub use typed::Command;
pub use typed::Event;
pub use types::*;

Modules§

action
The vocabulary of browser operations.
action_builder
Assembling a sequence of BrowserActions to run in one go.
action_parse
Reading a BrowserAction out of the flat JSON an LLM tool call sends.
agent
Running BrowserActions against a tab and reporting how each one went.
client
Low-level CDP client: one method per DevTools Protocol command.
cluster
A worker pool of pre-created tabs, distributing tasks with retries (puppeteer-cluster style). See Cluster.
config
Connection and viewport settings for BrowserAgent::connect_with_config.
discovery
Finding a browser and its targets over Chrome’s HTTP endpoint.
dom
Reading the document tree.
error
The crate’s error type and Result alias.
keys
Keyboard names as Input.dispatchKeyEvent wants them.
methods
CDP method names, one module per protocol domain.
network
Network and Fetch domain commands (cookies, headers, request interception), added to CdpClient here.
page
Page, Emulation, and DOM mutation commands, added to CdpClient here.
protocol
Typed CDP: the protocol’s own types, one parameters and one result struct per command, and one payload struct per event.
runtime
Evaluating JavaScript in the page.
screenshot
Capturing the page as a PNG.
session
Flat CDP sessions: addressing commands and attributing events to a target other than the one the connection was opened to.
typed
Sending a CDP command as a type, and reading an event back as one.
types
Plain data types returned by CDP commands and events.