This page describes the public API surface of seleniumbase-rs, the stability
guarantees that apply, and how to integrate the crate with foreign code.
Public modules#
The crate root exposes the following modules:
| Module | Purpose |
|---|---|
api | BaseCase, capability traits, tours, charts, recorder, scenario runner, CDP page/driver helpers. |
artifacts | The latest_logs folder, collision-free artifact names, and the check that keeps a caller-supplied file name inside it. |
behave | Gherkin/BDD parser, step registry, and runner. |
browser | BrowserConfig, BrowserSession, driver launching, and optional Playwright session. |
cli | sbrs command-line script implementations. |
common | Decorators, obfuscation, and shared exception types. |
config | Settings, proxy lists, and ad-block lists. |
core | Test result records and the JSON and HTML reports made from them. |
error | SeleniumBaseError and the Result<T> alias. |
js_code | quote, which turns a Rust string into a JavaScript string literal for the scripts the crate builds. |
macros | #[macro_export] convenience macros (also re-exported at the crate root). |
mcp | MCP servers (cdp, driver, sb) and the types to build more: Host, ToolDef, Args, Output, ToolError. Behind the mcp-server feature. |
profile_payloads | External browser profile payload parsing and conversion. |
plugins | Cloud/logging plugin interfaces. |
resources | Where downloaded browser drivers live and how a chromedriver is found. |
sb_cdp | Pure CDP engine: Browser, Page, Locator, input, human-paced input, cookies/storage/window/emulation, retrying expectations, CAPTCHA solving, isolated BrowserContexts, a BrowserPool with an in-memory SessionStore, and (with test-util) a mock browser. |
stealth | Undetected-chrome options, evasions, the evasion provider registry, fingerprint profiles, humanization helpers, binary patcher, and CDP reactor. session_registry (the registry the Pure CDP engine runs) is Experimental: it serves the stealth layer, which lives in seleniumbase-rs-stealth since 0.3.0. |
utilities | Selenium IDE, Grid, and Python-to-Rust importer. |
utils | Selectors, shadow DOM helpers, translations, and extension builders. |
The modules wire, scrape and impersonate were removed in 0.3.0. They are
the crates seleniumbase-rs-codec, seleniumbase-rs-scrape and
seleniumbase-rs-mimic of
seleniumbase-rs-stealth
now, which build on the public items of sb_cdp and stealth listed here.
Crate-root re-exports#
The most common types are re-exported from the crate root for convenience:
| Type | Re-exported from crate root |
|---|---|
BaseCase | yes |
BrowserConfig, Browser, DriverMode, BrowserSession | yes |
Selector | yes |
Fingerprint, StealthPolicy | yes |
BatteryProfile, ConnectionProfile, SpeechVoice, BrandVersion, ClientHints, HumanizeConfig, CoherenceReport | yes |
EvasionProvider, EvasionContext, EvasionConfig, EvasionRegistry, default_registry | yes |
session_registry, SESSION_OMITTED_PROVIDERS | yes, Experimental (serves the stealth layer) |
ChromedriverPatcher, ChromeBinaryPatcher, EnginePatch, engine_spoofing_args | yes |
Chart, ChartType, TourTheme, Gui | yes |
run_browser_test, run_cdp_test, RunSettings, PauseKind, Settings, SettingsOverrides, RuntimeConfig, LogFormat | yes |
run_browser_test_boxed, BrowserTestFuture | yes, Deprecated |
AssertionApi, BrowserApi, ElementApi, ScreenshotApi | yes |
Result<T>, SeleniumBaseError, ResultExt | yes |
import_python, ImportDiagnostic, ImportOptions, ImportResult, ImportSeverity, PythonSource | yes |
#[macro_export] macros such as selector!, sb_test!, sb_open!, and
fingerprint! are also imported from the crate root:
Capability traits#
The public API is organized into capability traits in api::traits. They are
implemented by BaseCase (WebDriver) and by sb_cdp::Page (Pure CDP), and can
be used to write helpers that run on either engine. None of their signatures
mentions an engine’s own types:
| Trait | Responsibility |
|---|---|
BrowserApi | Navigation and lifecycle: open, quit, refresh, go_back, go_forward, get_title, get_url. |
ElementApi | Interacting with elements: click, double_click, type_text, get_text, get_attribute. (Holding an element handle is engine-specific: BaseCase::find_element returns a thirtyfour::WebElement, a Page offers locator(..).) |
AssertionApi | Test assertions: assert_title, assert_element, assert_text, assert_no_js_errors. |
ScreenshotApi | Screenshot capture: save_screenshot, screenshot_as_png. |
Both engines implement the capability traits; a helper depends on the traits, not on an engine.
Use these traits when writing helpers that should work with any type exposing the same capability, or as a blueprint for adding new cross-cutting concerns:
ABI note#
Rust does not have a stable application binary interface. Do not pass
seleniumbase-rs types across a dynamic-library boundary or assume a fixed
memory layout.
If you need to drive the crate from another language, write a
small extern "C" shim that accepts C-compatible arguments and internally
builds a BaseCase or calls the Rust API:
The default toolchain, target, and compiler version can all change the layout of public structs.
Treat the Rust API as source-compatible only.
Versioning policy#
seleniumbase-rs follows Semantic Versioning:
- Patch releases fix bugs without changing the public API.
- Minor releases add functionality in a backward-compatible way.
- Major releases may break the public API.
Because the crate is pre-1.0, minor releases (0.x) may contain breaking
changes. Pin to an exact version or a narrow range in production.
Feature flags#
The crate uses Cargo features to keep heavy dependencies off by default:
| Feature | Effect | Default |
|---|---|---|
playwright | Enables the rustwright-backed Playwright-compatible driver. | no |
s3 | Enables AWS S3 artifact uploads. | no |
azure | Enables Azure Blob Storage artifact uploads. | no |
gcp | Enables Google Cloud Storage artifact uploads. | no |
mcp-server | Enables the mcp module and builds the sbrs-mcp binary using rmcp. | no |
test-util | Exposes sb_cdp::Browser::new_mocked and MockCtrl for testing code that drives pages without Chrome. | no |
turso | Enables the storage module (ResultStore, ProfileVault, built on the embedded Turso database) and the sbrs report command. A Turso dependency needs Rust 1.90, which the crate’s rust-version (1.99) already covers. | no |
full-tracing | Enables tracing-timing histograms. | no |
error-backtrace | Reserved for future backtrace capture on every SeleniumBaseError. | no |
The experimental features scrape and impersonate were removed in 0.3.0 (see
the modules above).
When adding feature-gated code, use #[cfg(feature = "...")] and declare the
dependency as optional = true in Cargo.toml.
Error design#
SeleniumBaseError is a rich, structured error enum:
- Element errors carry the selector and detected strategy:
ElementNotFound,ElementNotInteractable,StaleElement,InvalidSelector. - Lifecycle errors carry the binary path or URL:
BrowserLaunch,BrowserDisconnected,Navigation,SessionNotStarted. - Subsystem errors give context without string parsing:
Patcher,Stealth,Network,Download,Screenshot,Pdf,CdpDriver,Playwright,Mcp,PythonMigration.
Every error exposes:
A stable snake_case tag for dashboards.
true for retryable network/disconnect/timeout failures.
true for the Skipped variant.
A one-sentence remediation hint when available.
Structured tracing::error! events.
Use the ResultExt trait to attach context:
What is not covered#
stealth::providers::session_registry is not yet a stable API. It serves the
experimental stealth layer of seleniumbase-rs-stealth: its names and behaviour may
change in any release, even a patch release, as measurements and reviews come in.
Internal helper modules, #[doc(hidden)] items, and items under
api::base_case_impls are implementation details. They may change without a
major version bump. Rely only on the public modules and re-exports listed
above.
API stability checklist for consumers#
- Import types from the crate root or documented public modules.
- Avoid relying on paths inside
api::base_case_implsor#[doc(hidden)]items. - Pin the crate version in production.
- Do not pass
seleniumbase-rstypes across FFI boundaries without a C shim. - Test feature-gated code with the same feature set you ship.