Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
rpage đĻđ
English | įŽäŊ䏿
A Rust browser-automation library inspired by DrissionPage â CDP browser control + HTTP session + shared cookies, in one crate.
rpage drives a real Chrome/Chromium over the DevTools Protocol and speaks
plain HTTP (reqwest) in the same API, with cookies shared between the two. It
aims for the ergonomics of DrissionPage with parity-or-better coverage of
Playwright's most useful features (response mocking, semantic locators,
actionability waits).
[]
= "1"
Why rpage
- One call to start â
WebPage::new()detects Chrome, launches it, connects over CDP. - No automation fingerprint â never passes
--enable-automation; behaves like a hand-opened browser. - Dual mode â browser (CDP) and HTTP session in one API, with cookie sync and
to_session()/to_chromium()switching. - Smart waiting â
get()waits for load;ele()/eles()auto-retry; click waits for actionability. - Sync and async â full async API, plus a zero-
awaitSyncPagewrapper. - Unicode-perfect input â
fill()types Chinese/any Unicode via CDPinsertText. - Rich locators â CSS, XPath, text/attr operators (
=:^$), same-element@@/@|, chains. - Network superpowers â capture request/response bodies, mock responses (
route.fulfill), intercept/redirect/block, raw CDP passthrough.
Quick start
use *;
async
Chaining
page.goto.await?
.type_text.await?
.click_ele.await?;
Sync API â no await, no #[tokio::main]
use SyncPage;
Locator syntax
Text/attribute operators follow DrissionPage: = exact, : contains, ^ starts-with, $ ends-with.
| Syntax | Meaning |
|---|---|
#id, .class, tag, css:âĻ |
CSS |
xpath:âĻ |
XPath |
@class=btn / @class:btn / @class^btn / @class$btn |
attribute exact / contains / prefix / suffix |
text=Login / text:Login / text^Log / text$in |
text exact / contains / prefix / suffix |
tag:div@@class=x@@text:y |
same-element AND (all conditions) |
| `@ | class=a@ |
a@@@b@@@c |
descendant chain (rpage extension) |
Non-CSS locators fall back to a JS document.evaluate XPath query automatically.
Capabilities
Below is a tour of the high-value APIs. The full API (580+ methods) is on docs.rs/rpage.
Elements
let el = page.ele.await?;
el.click.await?; // CDP click, JS fallback, waits actionable
el.fill.await?; // clear + type (Unicode)
el.right_click.await?; el.double_click.await?;
el.drag_to.await?; // or drag_to_offset(dx, dy)
el.select.await?; // <select>
el.upload_file.await?;
el.is_visible.await; el.is_in_viewport.await; el.is_alive.await; // states
let parent = el.parent.await?; // parent/first_child/next/prev/children
el.wait_for_visible.await?; // + hidden/enabled/clickable/stale/text/attribute
Semantic locators (Playwright get_by_*)
page.get_by_text.await?;
page.get_by_role.await?; // explicit + implicit ARIA roles
page.get_by_label.await?; // aria-label / <label for> / wrapping
page.get_by_placeholder.await?;
page.get_by_test_id.await?; // data-testid
Network capture & mocking
// Raw CDP passthrough for anything not wrapped:
page.run_cdp.await?;
// Capture full request+response+body (DrissionPage listen.wait/steps):
page.listen_start.await?;
page.ele.await?.click.await?;
let pkt = page.wait_data_packet.await?; // wait for one
println!;
for p in page.data_packets.await
// Mock a response without hitting the network (Playwright route.fulfill):
let guard = page.enable_intercept.await?;
page.click_ele.await?;
for req in guard.paused_requests
guard.disable.await?;
Static-snapshot elements (DrissionPage s_ele)
let rows = page.s_eles.await?; // parse current HTML once, no live CDP
for row in &rows
Dual mode, cookies, lifecycle
page.to_session.await?; // browser â HTTP
let resp = page.session_get.await?;
page.to_chromium.await?; // HTTP â browser
page.save_cookies_to_file.await?;
page.quit.await?;
More (see docs.rs)
Tabs, scrolling, screenshots/PDF, iframes, alerts, downloads, console &
WebSocket capture, performance metrics, init scripts & CSS injection, device
emulation (DPR/touch/geolocation/timezone), window management, ActionChain,
stealth, and an Agent interface (interactive_elements(),
page_snapshot(), smart_click(), smart_fill()) for LLM-driven automation.
Configuration
use ;
let page = with_options.await?;
Set RPAGE_CHROME_PATH to point at a specific Chrome/Chromium binary.
Requirements
- A locally installed Chrome or Chromium.
- Rust 1.75+ (2021 edition).
Stability
rpage follows SemVer. Starting at 1.0, breaking
API changes will only land in a new major version.
License
MIT