Expand description
Firefox WebDriver - Undetectable browser automation library.
This library provides a high-level API for automating Firefox browser using a custom WebExtension-based architecture.
§Architecture
The driver follows a client-server model:
- Local End (Rust): Sends commands, receives events via WebSocket
- Remote End (Extension): Executes commands in Firefox, emits events
Key design principles:
Driverowns a sharedConnectionPool(single WebSocket port)- Each
Windowowns: Firefox process + profile, references shared pool - Protocol uses
module.methodNameformat (BiDi-inspired) - Elements stored by reference in content script
Map(undetectable) - Event-driven architecture (no polling)
§Quick Start
use firefox_webdriver::{Driver, Result};
#[tokio::main]
async fn main() -> Result<()> {
// Build driver with Firefox binary and extension paths
let driver = Driver::builder()
.binary("/path/to/firefox")
.extension("/path/to/extension")
.build()
.await?;
// Spawn a headless browser window
let window = driver.window().headless().spawn().await?;
let tab = window.tab();
// Navigate and interact
tab.goto("https://example.com").await?;
let title = tab.get_title().await?;
println!("Page title: {}", title);
Ok(())
}§Modules
| Module | Description |
|---|---|
browser | Browser entities: Window, Tab, Element |
driver | Driver factory and configuration |
error | Error types and Result alias |
identifiers | Type-safe ID wrappers |
protocol | WebSocket message types (internal) |
transport | WebSocket transport layer (internal) |
§Features
- Undetectable: No
navigator.webdriverflag, no detectable globals - Event-driven: DOM mutations, network events push to client
- CSP bypass: Script execution via
browser.scriptingAPI - Parallel automation: 300+ concurrent windows supported
Re-exports§
pub use browser::BodyAction;pub use browser::By;pub use browser::Cookie;pub use browser::Element;pub use browser::FrameInfo;pub use browser::HeadersAction;pub use browser::ImageFormat;pub use browser::InterceptedRequest;pub use browser::InterceptedRequestBody;pub use browser::InterceptedRequestHeaders;pub use browser::InterceptedResponse;pub use browser::InterceptedResponseBody;pub use browser::Key;pub use browser::ProxyConfig;pub use browser::ProxyType;pub use browser::RequestAction;pub use browser::RequestBody;pub use browser::ResponseAction;pub use browser::ScreenshotBuilder;pub use browser::Tab;pub use browser::Window;pub use driver::Driver;pub use driver::DriverBuilder;pub use driver::ExtensionSource;pub use driver::FirefoxOptions;pub use driver::Profile;pub use error::Error;pub use error::Result;pub use identifiers::ElementId;pub use identifiers::FrameId;pub use identifiers::InterceptId;pub use identifiers::RequestId;pub use identifiers::ScriptId;pub use identifiers::SessionId;pub use identifiers::SubscriptionId;pub use identifiers::TabId;