Skip to main content

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.

Quickstart#

Rust 1.99 or newer and a Chromium-based browser (Chrome, Chromium or Edge) are all you need.

Create a project#

Terminal

Add the dependencies#

The crate is installed from git (it is not on crates.io). tokio runs the async code.

Cargo.toml

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.

src/main.rs

Run it#

Terminal

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.

Tip

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:

  1. Create a Rust project, add seleniumbase-rs, and run your first test.
  2. Choose between WebDriver, CDP, UC, and Playwright browser modes.
  3. Use selectors, waits, assertions, and the recorder to write maintainable tests.
  4. Configure runs with BrowserConfig, sbase_config.toml, and SB_* environment variables.
  5. Apply anti-detection measures including fingerprints, binary patching, and engine spoofing arguments.
  6. Integrate with cloud storage, Gherkin, Selenium IDE, PDF tools, charts, tours, and the sbrs CLI.
  7. Operate the test suite reliably in CI/CD with tracing, Docker, and shell completions.

What is included#

  • Browser modes: WebDriver, CDP, UC (Undetected Chromedriver), and an optional rustwright-based Playwright-compatible engine.
  • BaseCase API: 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, Fingerprint presets, StealthPolicy, and a priority-ordered EvasionProvider registry.
  • Low-code tooling: JSON scenario runner, Python importer, Selenium IDE parser, Gherkin runner, and action recorder.
  • Operational tooling: sbrs CLI, Commander TUI, shell completions, Docker image, SB_* environment configuration, and structured tracing output.
  • Optional integrations: S3, Azure Blob Storage, Google Cloud Storage, and an MCP server, each behind a Cargo feature flag.

How to use this book#

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.

Note

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.

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.