Expand description
§playwright-cdp
Drive Chromium-based browsers directly via the Chrome DevTools Protocol (CDP) over a single WebSocket — no Playwright Node.js driver required.
The public API mirrors Playwright’s shape (Playwright, BrowserType,
Browser, BrowserContext, Page, Locator, builder option structs,
async + Result<T>), but it speaks CDP natively instead of proxying
through Playwright’s driver.
// Three-layer entry, mirroring playwright-rust (no driver spawned here).
let browser = Playwright::launch().await?
.chromium()
.launch_with_options(LaunchOptions::default()).await?;
let page = browser.new_page().await?;
page.goto("https://example.com", None).await?;
let title: String = page.evaluate("document.title").await?;
println!("{title}");
browser.close().await?;Browser::launch also works directly for callers who don’t need the
Playwright/BrowserType layer.
Re-exports§
pub use api_request::APIRequestContext;pub use api_request::APIResponse;pub use assertions::expect;pub use assertions::expect_page;pub use assertions::LocatorAssertions;pub use assertions::PageAssertions;pub use browser::Browser;pub use browser_context::BrowserContext;pub use browser_type::BrowserType;pub use browser_type::Engine;pub use cdp::session::CdpSession;pub use download::Download;pub use element_handle::ElementHandle;pub use error::Error;pub use error::Result;pub use file_chooser::FileChooser;pub use frame::Frame;pub use frame_locator::FrameLocator;pub use keyboard::Keyboard;pub use locator::Locator;pub use mouse::Mouse;pub use page::Dialog;pub use page::Page;pub use playwright::Playwright;pub use request::Request;pub use response::Response;pub use options::APIRequestOptions;pub use route::Route;pub use route::RouteContinueOptions;pub use route::RouteFulfillOptions;pub use types::AriaRole;pub use types::ConsoleMessage;pub use types::MouseButton;pub use types::NameValue;pub use types::OriginStorage;pub use types::Position;pub use types::StorageState;pub use types::Viewport;pub use tracing::Tracing;pub use touchscreen::Touchscreen;pub use worker::Worker;
Modules§
- api_
request - Standalone HTTP client mirroring Playwright’s
APIRequestContext/APIResponse. - assertions
- Playwright-style
expect(locator)/expect(page)assertions. - browser
Browser— top-level entry point. Launches/connects to Chromium over CDP.- browser_
context BrowserContext— an isolated context (incognito-style), owning pages, init scripts, cookies, and defaults.- browser_
process - Chrome/Chromium process management: executable discovery, spawning with
--remote-debugging-port, DevToolsActivePort discovery, and/json/versionresolution to the browser WebSocket endpoint. - browser_
type BrowserType— a browser engine entry point (Playwright-shaped).- cdp
- Low-level CDP plumbing: WebSocket transport, wire-format messages, the multiplexing connection, and the per-target session.
- download
Download— file-download capture via the CDPPagedownload events.- element_
handle ElementHandle— a persistent handle to a resolved DOM element (a CDPRemoteObjectId).- error
- Error types for the crate.
- file_
chooser FileChooser— file-chooser interception via the CDPPagedomain.- frame
Frame— a frame within a page (the main document, or an<iframe>).- frame_
locator FrameLocator— a Playwright-style locator scoped to a same-origin<iframe>’scontentDocument.- keyboard
Keyboard— input via the CDPInputdomain.- locator
Locator— a Playwright-style element reference resolved lazily against the page’s selector engine.- mouse
Mouse— pointer input via the CDPInputdomain.- options
- Builder option structs mirroring Playwright’s option objects.
- page
Page— a browser tab. Tracks its main execution context, drives navigation, evaluation, screenshots, and produces locators.- playwright
Playwright— the top-level entry point (Playwright-shaped).- request
Request— an HTTP request observed via the CDPNetworkdomain.- response
Response— an HTTP response observed via the CDPNetworkdomain.- route
Route— network interception via the CDPFetchdomain.- selectors
- Selector-engine injection and element resolution.
- touchscreen
Touchscreen— touch input via the CDPInput.dispatchTouchEvent.- tracing
Tracing— performance tracing via the browser-level CDPTracingdomain.- types
- Shared value types used across the public API.
- worker
Worker— web/service/shared-worker capture via the CDPTargetdomain.