Skip to main content

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:

ModulePurpose
apiBaseCase, capability traits, tours, charts, recorder, scenario runner, CDP page/driver helpers.
artifactsThe latest_logs folder, collision-free artifact names, and the check that keeps a caller-supplied file name inside it.
behaveGherkin/BDD parser, step registry, and runner.
browserBrowserConfig, BrowserSession, driver launching, and optional Playwright session.
clisbrs command-line script implementations.
commonDecorators, obfuscation, and shared exception types.
configSettings, proxy lists, and ad-block lists.
coreTest result records and the JSON and HTML reports made from them.
errorSeleniumBaseError and the Result<T> alias.
js_codequote, 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).
mcpMCP servers (cdp, driver, sb) and the types to build more: Host, ToolDef, Args, Output, ToolError. Behind the mcp-server feature.
profile_payloadsExternal browser profile payload parsing and conversion.
pluginsCloud/logging plugin interfaces.
resourcesWhere downloaded browser drivers live and how a chromedriver is found.
sb_cdpPure 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.
stealthUndetected-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.
utilitiesSelenium IDE, Grid, and Python-to-Rust importer.
utilsSelectors, shadow DOM helpers, translations, and extension builders.
Note

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:

TypeRe-exported from crate root
BaseCaseyes
BrowserConfig, Browser, DriverMode, BrowserSessionyes
Selectoryes
Fingerprint, StealthPolicyyes
BatteryProfile, ConnectionProfile, SpeechVoice, BrandVersion, ClientHints, HumanizeConfig, CoherenceReportyes
EvasionProvider, EvasionContext, EvasionConfig, EvasionRegistry, default_registryyes
session_registry, SESSION_OMITTED_PROVIDERSyes, Experimental (serves the stealth layer)
ChromedriverPatcher, ChromeBinaryPatcher, EnginePatch, engine_spoofing_argsyes
Chart, ChartType, TourTheme, Guiyes
run_browser_test, run_cdp_test, RunSettings, PauseKind, Settings, SettingsOverrides, RuntimeConfig, LogFormatyes
run_browser_test_boxed, BrowserTestFutureyes, Deprecated
AssertionApi, BrowserApi, ElementApi, ScreenshotApiyes
Result<T>, SeleniumBaseError, ResultExtyes
import_python, ImportDiagnostic, ImportOptions, ImportResult, ImportSeverity, PythonSourceyes

#[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:

TraitResponsibility
BrowserApiNavigation and lifecycle: open, quit, refresh, go_back, go_forward, get_title, get_url.
ElementApiInteracting 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(..).)
AssertionApiTest assertions: assert_title, assert_element, assert_text, assert_no_js_errors.
ScreenshotApiScreenshot 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#

Warning

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:

C shim

The default toolchain, target, and compiler version can all change the layout of public structs.

Info

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.
Warning

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:

FeatureEffectDefault
playwrightEnables the rustwright-backed Playwright-compatible driver.no
s3Enables AWS S3 artifact uploads.no
azureEnables Azure Blob Storage artifact uploads.no
gcpEnables Google Cloud Storage artifact uploads.no
mcp-serverEnables the mcp module and builds the sbrs-mcp binary using rmcp.no
test-utilExposes sb_cdp::Browser::new_mocked and MockCtrl for testing code that drives pages without Chrome.no
tursoEnables 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-tracingEnables tracing-timing histograms.no
error-backtraceReserved 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:

category()&'static str#

A stable snake_case tag for dashboards.

is_transient()bool#

true for retryable network/disconnect/timeout failures.

is_skipped()bool#

true for the Skipped variant.

hint()Option<String>#

A one-sentence remediation hint when available.

log() / log_in_context(op)#

Structured tracing::error! events.

Use the ResultExt trait to attach context:

What is not covered#

Warning

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.

Note

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_impls or #[doc(hidden)] items.
  • Pin the crate version in production.
  • Do not pass seleniumbase-rs types across FFI boundaries without a C shim.
  • Test feature-gated code with the same feature set you ship.