Welcome to the SeleniumBase for Rust book. This guide explains how to build
browser automation scripts, end-to-end tests, and operational tooling with
seleniumbase-rs.
The crate is a Rust port of the Python SeleniumBase framework. It keeps the
parts that make SeleniumBase productive—the large BaseCase API, anti-detection
features, recorder, and CLI—while replacing the Python runtime with Rust’s type
system, async runtime, and native distribution model.
Create a Rust project, add seleniumbase-rs, and run your first test.
BaseCase, selectors, waits and assertions for maintainable tests.
Keep a similar API while gaining compile-time guarantees.
UC mode, CDP, pure CDP, fingerprints and binary patching.
The sbrs CLI, Commander, and the MCP servers for AI agents.
Security, reliability, performance and how it compares.
Browser plugins as Rust crates: privacy hardening, block resources, load extensions, run WebAssembly.
Wire fingerprints, identities and the browser scraper (experimental).
Quickstart#
Rust 1.99 or newer and a Chromium-based browser (Chrome, Chromium or Edge) are all you need.
Create a project#
Add the dependencies#
The crate is installed from git (it is not on crates.io). tokio runs the async
code.
Write a test#
Pick an engine. The pure CDP engine talks to Chrome directly and needs no
driver; BaseCase uses WebDriver and starts chromedriver for you.
Run it#
The test opens the login page, signs in and checks the welcome text. A failed check ends the program with an error that names the selector.
No Rust project yet? The sbrs command line drives a browser on its own:
cargo install --git https://github.com/MustCodeAl/seleniumbase-rs seleniumbase-rs-cli,
then sbrs --headless open https://example.com. See the CLI TL;DR.
Who this book is for#
- Rust developers writing browser tests for the first time.
- Teams migrating from Python SeleniumBase or Selenium who want to keep a similar API while gaining compile-time guarantees.
- Automation engineers who need undetected browser execution, CDP control, or cloud artifact uploads.
- Operators who want a small native CLI (
sbrs) and Docker image for CI/CD.
What you will learn#
By reading this book you will learn how to:
- Create a Rust project, add
seleniumbase-rs, and run your first test. - Choose between WebDriver, CDP, UC, and Playwright browser modes.
- Use selectors, waits, assertions, and the recorder to write maintainable tests.
- Configure runs with
BrowserConfig,sbase_config.toml, andSB_*environment variables. - Apply anti-detection measures including fingerprints, binary patching, and engine spoofing arguments.
- Integrate with cloud storage, Gherkin, Selenium IDE, PDF tools, charts, tours,
and the
sbrsCLI. - Operate the test suite reliably in CI/CD with tracing, Docker, and shell completions.
What is included#
- Browser modes: WebDriverThe Selenium protocol: the test talks to chromedriver, which drives the browser., CDPChrome DevTools Protocol: the browser's own debugging protocol, spoken over a WebSocket. Pure CDP engine, UCUndetected Chromedriver mode: a browser launch and session setup that avoid common bot checks; the driver itself is not patched. Undetected (UC) mode (Undetected Chromedriver), and an optional
rustwright-based Playwright-compatible engine. BaseCaseAPI: more than 200 methods for navigation, element interaction, assertions, waits, frames, windows, cookies, storage, uploads, PDF handling, HTML parsing, and more.- Stealth stack:
ChromedriverPatcher,ChromeBinaryPatcher,Fingerprintpresets,StealthPolicy, and a priority-orderedEvasionProviderregistry. - Low-code tooling: JSON scenario runner, Python importer, Selenium IDE parser, Gherkin runner, and action recorder.
- Operational tooling:
sbrsCLI, Commander TUI, shell completions, Docker image,SB_*environment configuration, and structuredtracingoutput. - Optional integrations: S3, Azure Blob Storage, Google Cloud Storage, and an MCP server, each behind a Cargo feature flag.
How to use this book#
Start with Getting Started and then read Writing Browser Tests and Waits and Assertions.
Jump to Migrate Python Tests and then read Selectors for the differences in selector syntax and test lifecycle.
Read Undetected (UC) Mode, Fingerprint & Stealth Profiles, and Binary Patching in that order.
Keep CLI Usage and Common Problems handy.
Current status#
Every API of Python SeleniumBase 4.55.2 has a recorded status in the parity table. Development happens on MustCodeAl/seleniumbase-rs, and releases are tagged there.
The crate is not on crates.io yet: install it from a release tag (see Building and installing).
The ecosystem#
Companion projects live in their own repositories and are documented on this site: see the Ecosystem page.
Plugin framework and community plugins for seleniumbase-rs
Experimental stealth layer for seleniumbase-rs: TLS/HTTP2 wire formats, a scraping runtime and a browser-identical HTTP client (codec, scrape, mimic)
Drive a Tauri app's webview from seleniumbase-rs tests on macOS, Windows and Linux (WebDriver inside the app)
Browser extensions for seleniumbase-rs: a recorder that exports Rust tests, an element inspector, and a Chrome DevTools Recorder export
Homebrew tap for seleniumbase-rs (sbrs)
Build this book locally#
Install mdBook, then run from the repository root:
mdbook serve --open serves the book and opens it. mdbook build builds a
static copy. The built HTML is written to the book/ directory.