1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
//! # ferrous-browser
//!
//! Full browser automation in Rust. No Node.js. No compromises. Single binary.
//!
//! ferrous-browser is a native Rust library for Chrome DevTools Protocol (CDP)
//! communication, enabling full browser automation without Node.js.
//!
//! ## Quick Start
//!
//! ```no_run
//! use ferrous_browser::{Browser, BrowserConfig, WaitUntil};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Launch Chrome with defaults (headless, 1280×720, 30 s timeout)
//! let browser = Browser::launch_chrome(None).await?;
//!
//! // Create a new page/tab
//! let page = browser.new_page().await?;
//!
//! // Navigate to a website
//! page.goto("https://example.com", WaitUntil::Load).await?;
//!
//! // Get the HTML content
//! let html = page.content().await?;
//! println!("Page HTML: {}", html);
//!
//! // Take a screenshot
//! let png_bytes = page.screenshot().await?;
//! std::fs::write("screenshot.png", png_bytes)?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## Features
//!
//! - **Zero Node.js dependency** — Pure Rust implementation using tokio
//! - **Single binary deployment** — No external runtime required
//! - **Async-first API** — Built on tokio for high performance
//! - **Type-safe** — Rust's type system catches errors at compile time
//! - **Direct CDP access** — Full control over Chrome's DevTools Protocol
//! - **Locator API** — Playwright-style ergonomic element selectors
//!
//! ## Locator API
//!
//! ```no_run
//! use ferrous_browser::{Browser, WaitUntil};
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let browser = Browser::launch_chrome(None).await?;
//! let page = browser.new_page().await?;
//! page.goto("https://example.com", WaitUntil::Load).await?;
//!
//! // Locator API
//! page.locator("button#submit").click().await?;
//! page.locator("input[name=q]").type_text("hello").await?;
//! page.locator(".result").wait_for().await?;
//!
//! Ok(())
//! }
//! ```
//!
//! ## WaitUntil modes
//!
//! ```no_run
//! use ferrous_browser::{Browser, WaitUntil};
//!
//! # #[tokio::main]
//! # async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let browser = Browser::launch_chrome(None).await?;
//! let page = browser.new_page().await?;
//!
//! // DOM parsed, sub-resources may still load
//! page.goto("https://example.com", WaitUntil::DomContentLoaded).await?;
//!
//! // All resources loaded (default)
//! page.goto("https://example.com", WaitUntil::Load).await?;
//!
//! // No network requests for 500 ms (SPA-friendly)
//! page.goto("https://example.com", WaitUntil::NetworkIdle).await?;
//! # Ok(())
//! # }
//! ```
//!
//! ## Architecture
//!
//! ferrous-browser is built on a layered architecture:
//!
//! - **CDPClient** — Low-level CDP message routing
//! - **Connection** — WebSocket lifecycle management
//! - **Browser** — High-level browser control API
//! - **Page** — High-level page/tab automation API
//! - **Locator** — Lazy element handle for ergonomic element interaction
/// Chrome DevTools Protocol types and client
/// WebSocket connection management
/// Error types
/// Browser automation API
/// Page automation API
pub use ;
pub use ;
pub use ;