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
61pub use api_request::{APIRequestContext, APIResponse};
62pub use assertions::{expect, expect_page, LocatorAssertions, PageAssertions};
63pub use browser::Browser;
64pub use browser_context::BrowserContext;
65pub use browser_type::{BrowserType, Engine};
66pub use cdp::session::CdpSession;
67pub use download::Download;
68pub use element_handle::ElementHandle;
69pub use error::{Error, Result};
70pub use file_chooser::FileChooser;
71pub use frame::Frame;
72pub use frame_locator::FrameLocator;
73pub use keyboard::Keyboard;
74pub use locator::Locator;
75pub use mouse::Mouse;
76pub use page::{Dialog, Page};
77pub use playwright::Playwright;
78pub use request::Request;
79pub use response::Response;
80pub use options::APIRequestOptions;
81pub use route::{Route, RouteContinueOptions, RouteFulfillOptions};
82pub use types::{AriaRole, ConsoleMessage, MouseButton, NameValue, OriginStorage, Position, StorageState, Viewport};
83pub use tracing::Tracing;
84pub use touchscreen::Touchscreen;
85pub use worker::Worker;