Skip to main content

playwright_cdp/
lib.rs

1//! # playwright-cdp
2//!
3//! Drive Chromium-based browsers **directly** via the Chrome DevTools Protocol
4//! (CDP) over a single WebSocket — **no Playwright Node.js driver required**.
5//!
6//! The public API mirrors Playwright's shape (`Playwright`, `BrowserType`,
7//! `Browser`, `BrowserContext`, `Page`, `Locator`, builder option structs,
8//! `async + Result<T>`), but it speaks CDP natively instead of proxying
9//! through Playwright's driver.
10//!
11//! ```no_run
12//! # use playwright_cdp::{Playwright, BrowserType, options::LaunchOptions};
13//! # #[tokio::main]
14//! # async fn main() -> playwright_cdp::Result<()> {
15//! // Three-layer entry, mirroring playwright-rust (no driver spawned here).
16//! let browser = Playwright::launch().await?
17//!     .chromium()
18//!     .launch_with_options(LaunchOptions::default()).await?;
19//! let page = browser.new_page().await?;
20//! page.goto("https://example.com", None).await?;
21//! let title: String = page.evaluate("document.title").await?;
22//! println!("{title}");
23//! browser.close().await?;
24//! # Ok(())
25//! # }
26//! ```
27//!
28//! `Browser::launch` also works directly for callers who don't need the
29//! `Playwright`/`BrowserType` layer.
30
31pub mod api_request;
32pub(crate) mod aria_snapshot;
33pub mod assertions;
34pub mod browser;
35pub mod browser_context;
36pub mod browser_process;
37pub mod browser_type;
38pub mod cdp;
39pub mod download;
40pub mod element_handle;
41pub mod error;
42pub mod file_chooser;
43pub mod frame;
44pub mod frame_locator;
45pub mod keyboard;
46pub mod locator;
47pub mod mouse;
48mod network;
49pub mod options;
50pub mod page;
51pub mod playwright;
52pub mod request;
53pub mod response;
54pub mod route;
55pub mod selectors;
56pub mod tracing;
57pub mod touchscreen;
58pub mod types;
59pub mod worker;
60
61// --- Feature modules (filled by sub-agents; declared here so the crate
62// stays compilable while individual modules are authored). ---
63pub mod clock;
64pub mod coverage;
65pub mod video;
66pub mod web_storage;
67pub mod web_socket;
68pub mod js_handle;
69pub mod accessibility;
70pub mod har;
71
72pub use api_request::{APIRequestContext, APIResponse, ApiRequestContextOptions};
73pub use assertions::{expect, expect_page, LocatorAssertions, PageAssertions};
74pub use browser::Browser;
75pub use browser_context::BrowserContext;
76pub use browser_type::{BrowserType, Engine};
77pub use cdp::session::CdpSession;
78pub use download::Download;
79pub use element_handle::ElementHandle;
80pub use error::{Error, Result};
81pub use file_chooser::FileChooser;
82pub use frame::Frame;
83pub use frame_locator::FrameLocator;
84pub use keyboard::Keyboard;
85pub use locator::Locator;
86pub use mouse::Mouse;
87pub use page::{Dialog, Page};
88pub use playwright::Playwright;
89pub use request::Request;
90pub use response::Response;
91pub use options::APIRequestOptions;
92pub use route::{Route, RouteContinueOptions, RouteFetchOptions, RouteFetchResponse, RouteFulfillOptions};
93pub use types::{AriaRole, ConsoleMessage, MouseButton, NameValue, OriginStorage, Position, StorageState, Viewport};
94pub use tracing::Tracing;
95pub use touchscreen::Touchscreen;
96pub use worker::Worker;
97
98// --- New feature-module re-exports (Playwright-compatible handles). ---
99pub use accessibility::{Accessibility, AccessibilityNode, AccessibilitySnapshotOptions};
100pub use clock::{Clock, ClockInstallOptions};
101pub use coverage::{
102    Coverage, CSSCoverageEntry, CSSCoverageResult, JSCoverageEntry, JSCoverageResult,
103};
104pub use element_handle::ElementState;
105pub use har::{Har, HarEntry, HarRecorder, HarRequest, HarResponse, RouteFromHarOptions};
106pub use js_handle::JSHandle;
107pub use video::{Video, VideoStartOptions};
108pub use web_socket::{
109    FrameData, FrameDirection, WebSocket, WebSocketFrame, WebSocketHandshake,
110    WebSocketLiveEvent,
111};
112pub use web_storage::WebStorage;
113// Network detail DTOs surfaced by `Request` / `Response`.
114pub use network::{ServerAddr, SecurityDetails, Sizes, Timing};