rust_drission
rust_drission is a Rust browser automation library built on Chrome DevTools Protocol (CDP). Its public API is intentionally close to DrissionPage, and the recommended entry point for most usage is ChromiumPage.
rust_drission 是一个基于 Chrome DevTools Protocol (CDP) 的 Rust 浏览器自动化库。它的公开 API 尽量贴近 DrissionPage,大多数场景建议直接从 ChromiumPage 开始。
Why ChromiumPage
- One entry point for launch/connect, navigation, element lookup, JS execution, screenshots, cookies, and tab access
- DrissionPage-style locator strings such as
css:,xpath:,text:,id:,class:,tag: - Supports direct JS/CDP calls when the high-level API is not enough
- Keeps advanced capabilities available through
page.tab()andpage.browser()
Installation
[]
= "0.1.6"
Quick Start
use ;
Common Patterns
Launch a new Chrome
use ;
let page = new?;
Connect to an existing Chrome
Chrome must already be started with remote debugging enabled, for example:
chrome --remote-debugging-port=9222
Then connect:
use ChromiumPage;
let page = connect?;
Locate and operate on elements
page.input?;
page.click?;
if let Some = page.ele?
Run JavaScript
let result = page.run_js?;
let async_result = page.run_js_await?;
Use advanced page APIs
use Duration;
let tab = page.tab;
tab.wait_visible?;
tab.set_local_storage?;
Documentation
- Chinese guide: docs/usage.zh-CN.md
- English guide: docs/usage.en.md
- Skill guide for usage-oriented prompting: skills/rust_drission/SKILL.md
Notes
ChromiumPageis the recommended starting point. Usepage.tab()orpage.browser()only when you need lower-level control.Framesupport is aimed at same-origin iframes.listen()is available onPage, so withChromiumPageyou usually callpage.tab().listen()?.- Element lookup methods often return
Result<Option<Element>, CdpError>. Handle theNonecase explicitly.