Skip to main content

Crate zendriver

Crate zendriver 

Source
Expand description

Async, undetectable Chrome automation over the Chrome DevTools Protocol.

zendriver is the high-level browser-automation entry point built on a CDP-over-WebSocket transport. The crate aims to feel like Playwright / Puppeteer for Rust while staying explicit about its CDP underpinnings — every public type maps cleanly to a CDP surface, every action has a single-call escape hatch, and stealth is on by default.

See the user guide / mdBook for end-to-end walkthroughs covering installation, quickstart, stealth, multi-tab, frames, input, and migration guides from Playwright / zendriver (Python) / nodriver (Python).

§Quickstart

let browser = zendriver::Browser::builder().launch().await?;
let tab = browser.main_tab();
tab.goto("https://example.com").await?;
let title: String = tab.evaluate_main("document.title").await?;
println!("{title}");
browser.close().await?;

§Module layout

§Feature flags

FlagCratePurpose
expectin-treeexpect_request / expect_response / expect_dialog / expect_download
monitorin-treetab.monitor() persistent Stream<NetworkEvent> (HTTP / WebSocket / EventSource)
interceptionzendriver-interceptionFetch.*-backed request rewriting / abort
cloudflarezendriver-cloudflareCloudflare Turnstile bypass
impervazendriver-impervaImperva WAF / Incapsula bypass
fetcherzendriver-fetcherChrome-for-Testing download cache

Each gated module is re-exported here under #[cfg(feature = "...")] so downstream code can use zendriver::AbortReason etc. without depending on the sub-crate directly.

Re-exports§

pub use browser::Browser;
pub use browser::BrowserBuilder;
pub use browser::Channel;
pub use browser::PermissionType;
pub use browser_context::BrowserContext;
pub use cookies::Cookie;
pub use cookies::CookieJar;
pub use cookies::CookiePriority;
pub use cookies::CookieSourceScheme;
pub use cookies::SameSite;
pub use element::Element;
pub use element::actions::ClickOptions;
pub use error::BrowserError;
pub use error::Result;
pub use error::ZendriverError;
pub use frame::Frame;
pub use input::Key;
pub use input::KeyModifiers;
pub use input::KeySequence;
pub use input::MouseButton;
pub use input::SpecialKey;
pub use pdf::PdfBuilder;
pub use query::AriaRole;
pub use query::BoundingBox;
pub use query::FindBuilder;
pub use query::PageBox;
pub use request::RequestBuilder;
pub use request::Response;
pub use screenshot::Format;
pub use screenshot::ScreenshotBuilder;
pub use storage::Storage;
pub use tab::FrameResourceMatch;
pub use tab::IdleOptions;
pub use tab::ReadyState;
pub use tab::ReloadOptions;
pub use tab::ScrollOptions;
pub use tab::Tab;
pub use tab::UserAgentOverride;
pub use traits::Evaluable;
pub use traits::Queryable;
pub use window::WindowBounds;
pub use window::WindowState;
pub use monitor::FrameDirection;monitor
pub use monitor::MonitorBuilder;monitor
pub use monitor::MonitoredRequest;monitor
pub use monitor::MonitoredResponse;monitor
pub use monitor::NetworkEvent;monitor
pub use monitor::NetworkExchange;monitor
pub use monitor::NetworkMonitor;monitor
pub use expect::request::MatchedRequest;expect
pub use expect::request::RequestExpectation;expect
pub use expect::response::MatchedResponse;expect
pub use expect::response::ResponseExpectation;expect
pub use expect::dialog::DialogExpectation;expect
pub use expect::dialog::DialogType;expect
pub use expect::dialog::MatchedDialog;expect
pub use expect::download::DownloadExpectation;expect
pub use expect::download::DownloadProgressState;expect
pub use expect::download::DownloadState;expect
pub use expect::download::MatchedDownload;expect

Modules§

browser
Browser lifecycle: executable discovery, subprocess spawn, WS attach, graceful teardown.
browser_context
Per-BrowserContext lifecycle on top of CDP Target.createBrowserContext.
cookies
Browser-wide cookie store backed by CDP Network.*Cookies* methods.
element
Handle to a DOM node via CDP RemoteObjectId / BackendNodeId.
error
Error hierarchy for the zendriver crate.
expectexpect
Event expectation helpers (expect_request / expect_response / expect_dialog / expect_download).
frame
Handle to a single document frame within a crate::Tab.
input
Realistic + raw input simulation: mouse paths, keyboard dispatch, per-tab pointer/modifier state.
monitormonitor
Persistent network monitor: a Stream<NetworkEvent> over HTTP exchanges, WebSocket frames, and EventSource messages. Passive (Network domain) — read-only; use the interception feature (Fetch domain) to modify requests.
network_idle
Per-Tab in-flight network request tracker.
pdf
Chainable PDF export + MHTML snapshot for a Tab.
query
Element query builders (FindBuilder / FindAllBuilder) and the shared AriaRole / BoundingBox types.
request
Browser-context HTTP: tab.request() runs fetch in the page (cookies + CORS inherited) with an opt-in Network.loadNetworkResource bypass.
screenshot
Chainable screenshot capture for a Tab.
stealth
Stealth profile + fingerprint configuration re-exported from zendriver-stealth.
storage
Per-Tab DOM storage handle (localStorage / sessionStorage) backed by CDP DOMStorage.* methods.
tab
Per-page handle to a single CDP target session.
traits
Traits enabling generic code over Tab + Frame + Element.
window
OS-window bounds + state control for a Tab.

Structs§

CaptchaChallengeimperva
Imperva WAF / Incapsula bypass surface re-exports.
CaptchaSolutionimperva
Imperva WAF / Incapsula bypass surface re-exports.
CloudflareBypasscloudflare
Cloudflare Turnstile bypass re-exports.
Connection
Cheap-to-clone handle to the connection actor. All Tabs and Elements hold one of these (via Arc<...>); the actor itself runs in a separate tokio task.
CookieSnapshotimperva
Imperva WAF / Incapsula bypass surface re-exports.
DataDomeBypassdatadome
DataDome bypass surface re-exports. Gated by the datadome cargo feature. Drives a DataDome clearance flow against a single tab’s session.
DataDomeChallengedatadome
DataDome bypass surface re-exports. Gated by the datadome cargo feature. CAPTCHA escalation handed to a caller-supplied solver.
DataDomeSolutiondatadome
DataDome bypass surface re-exports. Gated by the datadome cargo feature. Token returned by a caller-supplied solver. For DataDome this is the solved datadome COOKIE value.
DetectionSnapshotimperva
Imperva WAF / Incapsula bypass surface re-exports.
Fetcherfetcher
Chrome-for-Testing fetcher re-exports.
FetcherProgressfetcher
Chrome-for-Testing fetcher re-exports.
HostMatcherinterception
Network interception API re-exports.
ImpervaBypassimperva
Imperva WAF / Incapsula bypass surface re-exports.
InterceptBuilderinterception
Network interception API re-exports.
InterceptHandleinterception
Network interception API re-exports.
PausedRequestinterception
Network interception API re-exports.
Persona
Unified fingerprint configuration. Every field optional → overlay semantics.
PersonaBuilder
Fluent builder for Persona. Every setter is optional.
RequestInfointerception
Network interception API re-exports.
RequestOverridesinterception
Network interception API re-exports.
ResponseInfointerception
Network interception API re-exports.
ResponseOverridesinterception
Network interception API re-exports.
Seed
A fingerprint seed. Serializes transparently as its u64 value.
SessionHandle
Cheap-to-clone handle binding a Connection to a specific CDP session.

Enums§

AbortReasoninterception
Network interception API re-exports.
CallError
Result of a CDP call: either a transport-level failure, or a structured JSON-RPC error returned by Chrome. Higher layers (the zendriver crate) map Rpc into the typed ZendriverError::Cdp variant.
CaptchaKindimperva
Imperva WAF / Incapsula bypass surface re-exports.
ClearanceOutcomecloudflare
Cloudflare Turnstile bypass re-exports.
CloudflareErrorcloudflare
Cloudflare Turnstile bypass re-exports.
DataDomeClearanceOutcomedatadome
DataDome clearance outcome (aliased to avoid colliding with the cloudflare and imperva ClearanceOutcome). Terminal outcome of a clearance attempt. All flow-terminals are Ok; only genuine faults are DataDomeError.
DataDomeErrordatadome
DataDome bypass surface re-exports. Gated by the datadome cargo feature. Error returned by DataDomeBypass operations. Faults only — flow terminals (cleared / blocked / timed-out / already-clear) are ClearanceOutcome variants, not errors.
DataDomeSurfacedatadome
DataDome bypass surface re-exports. Gated by the datadome cargo feature. Which DataDome surface a tab is currently showing.
FetcherChannelfetcher
Chrome-for-Testing fetcher re-exports.
FetcherErrorfetcher
Chrome-for-Testing fetcher re-exports.
FetcherPhasefetcher
Chrome-for-Testing fetcher re-exports.
ImpervaClearanceOutcomeimperva
Imperva-bypass clearance outcome (aliased to avoid colliding with the cloudflare crate’s ClearanceOutcome). Outcome of a successful wait_for_clearance.
ImpervaErrorimperva
Imperva WAF / Incapsula bypass surface re-exports.
ImpervaSurfaceimperva
Imperva WAF / Incapsula bypass surface re-exports.
InterceptionErrorinterception
Network interception API re-exports.
Platformfetcher
Chrome-for-Testing fetcher re-exports.
RequestStageinterception
Network interception API re-exports.
ResourceTypeinterception
Network interception API re-exports.
Strategy
How a resolved persona is applied to a surface in the page.
Surface
A fingerprint surface.
TransportError
Connection-level failure modes — anything that happens “below” a CDP response getting routed back to its caller.
UrlMatcher
Re-export the shared UrlMatcher used by expect_* and monitor. URL match predicate used by request/response expectations.
VersionSpecfetcher
Chrome-for-Testing fetcher re-exports.

Functions§

datadome_detect_surfacedatadome
DataDome bypass surface re-exports. Gated by the datadome cargo feature. Surface-only probe. Convenience for “which surface am I on” without driving a bypass.
detect_surfaceimperva
Imperva WAF / Incapsula bypass surface re-exports.
start
Convenience entry point: launch a Chrome instance with default settings.