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 api_request::ApiRequestContextOptions;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::RouteFetchOptions;pub use route::RouteFetchResponse;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;pub use accessibility::Accessibility;pub use accessibility::AccessibilityNode;pub use accessibility::AccessibilitySnapshotOptions;pub use clock::Clock;pub use clock::ClockInstallOptions;pub use coverage::Coverage;pub use coverage::CSSCoverageEntry;pub use coverage::CSSCoverageResult;pub use coverage::JSCoverageEntry;pub use coverage::JSCoverageResult;pub use element_handle::ElementState;pub use har::Har;pub use har::HarEntry;pub use har::HarRecorder;pub use har::HarRequest;pub use har::HarResponse;pub use har::RouteFromHarOptions;pub use js_handle::JSHandle;pub use video::Video;pub use video::VideoStartOptions;pub use web_socket::FrameData;pub use web_socket::FrameDirection;pub use web_socket::WebSocket;pub use web_socket::WebSocketFrame;pub use web_socket::WebSocketHandshake;pub use web_socket::WebSocketLiveEvent;pub use web_storage::WebStorage;
Modules§
- accessibility
Accessibility— accessibility-tree snapshot via the CDPAccessibilitydomain.- 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.
- clock
Clock— Playwright-style fake timers for a page.- coverage
Coverage— JS and CSS code-coverage collection for a page.- 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.- har
- HAR recording/replay (
route_from_har). - js_
handle JSHandle— a reference to a remote JavaScript object (a CDPRemoteObjectId) on a session.- 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.
- video
Video— page video capture via CDPPage.startScreencast.- web_
socket WebSocket— a captured WebSocket connection, reconstructed from CDPNetwork.webSocket*events.- web_
storage WebStorage—localStorage/sessionStorageaccess via the CDPDOMStoragedomain.- worker
Worker— web/service/shared-worker capture via the CDPTargetdomain.
Structs§
- Security
Details - TLS/SSL certificate details, derived from the CDP
Network.Response.securityDetailsobject. - Server
Addr - The remote server address a response came from.
- Sizes
- Size breakdown for a transferred resource, derived from CDP
Network.loadingFinished(encodedDataLength) and the response headers. - Timing
- Timing information for a request/response, derived from the CDP
Network.Response.timingobject. All times are Unix epoch milliseconds where applicable; durations are milliseconds.