Registry / testing / seleniumbase

seleniumbase

JSON →
library4.52.4pypypi✓ verified 23d ago

SeleniumBase is a complete web automation framework for end-to-end testing, built on top of the Selenium/WebDriver APIs. It simplifies browser automation with an intuitive syntax, built-in features for reliable interactions, and advanced capabilities like bot-detection avoidance. It supports various tasks from testing to web scraping and maintains a rapid release cadence with frequent patches.

pip install seleniumbase
INSTALL
IMPORT
SIG · SELENIUMBASE
S
seleniumbase
testingpythonv4.52.4
Install
18.9s avg
Import
2062ms
Disk
114MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v4.52.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 2.140s · 115MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 18.9s · import 1.984s · 117MB
114MB installed
● package 114MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

BaseCase
from seleniumbase import BaseCase
from seleniumbase.fixtures.base_case import BaseCase
Import BaseCase directly from seleniumbase for class-based tests.
SB
from seleniumbase import SB
Use the SB context manager for non-pytest script execution.
Driver
from seleniumbase import Driver
For direct, low-level WebDriver access with SeleniumBase enhancements.

This quickstart demonstrates a basic interaction with a demo page using the `SB()` context manager. It opens a URL, types text into an input field, clicks a button, asserts text presence, highlights an element, and then asserts the presence of another element. This format allows running SeleniumBase scripts without explicit pytest integration.

from seleniumbase import SB with SB() as sb: sb.open("https://seleniumbase.io/demo_page") sb.type("#myTextInput", "This is an automated test") sb.click("#myButton") sb.assert_text("Automation Practice", "h3") sb.highlight("#myButton") sb.sleep(1) sb.assert_element("tbody#tbodyId") print("Test completed successfully!")
seleniumbase --version
Debug
Known issues
gotchaSeleniumBase methods (`self.open()`, `sb.type()`, etc.) must be called within the `BaseCase` test class context (using `self`) or the `SB()` context manager instance. Calling them directly or outside this scope will result in errors like 'It looks like you are trying to call a SeleniumBase method from outside the scope of your test class's `self` object'.
fix
Ensure all SeleniumBase methods are invoked via the `self` object within a `BaseCase` inheriting class or an `SB()` context manager instance. For example, `self.open(url)` or `sb.open(url)`.
affects: All versions
gotchaElement detection can be less reliable in headless mode compared to visible browser mode, leading to 'Element Not Found' errors due to differences in page rendering or dynamic content loading. This is a common challenge with headless browser automation.
fix
Explicitly set the browser window size using `sb.set_window_size(width, height)` to simulate a real viewport, and consider adjusting user-agent strings to mimic real user behavior (`--user-agent="..."` command-line option).
affects: All versions
gotchaWeb scraping scripts using SeleniumBase can break unexpectedly if the target website's HTML structure, element selectors (CSS/XPath), or anti-bot mechanisms change. SeleniumBase's auto-waiting features mitigate flakiness but cannot prevent issues arising from fundamental site changes. Additionally, anti-bot services and CAPTCHAs (like reCAPTCHA) can still detect automation, especially after browser updates, even with stealth options.
fix
Regularly verify and update selectors. Employ robust error handling and retry mechanisms. For anti-bot issues, experiment with `--uc` (undetected-chromedriver) mode, `--user-agent` rotation, and other stealth options, but be aware that detection is an ongoing cat-and-mouse game. Consider using proxy integration for IP rotation.
affects: All versions
breakingAs of recent versions (e.g., around v4.x), `allure-pytest` is no longer bundled with SeleniumBase and must be installed separately if you wish to generate Allure Reports.
fix
If you use Allure Reports, manually install `allure-pytest` with `pip install allure-pytest`.
affects: >=4.0
gotchaOverriding `setUp()` or `tearDown()` methods in a `BaseCase` subclass requires careful invocation of `super().setUp()` and `super().tearDown()` to ensure SeleniumBase's core setup and teardown functionalities (like browser initialization/quitting, screenshot capture) are not inadvertently bypassed or corrupted. Calling `super()` at the wrong point, or not at all, can lead to broken tests or resource leaks.
fix
When customizing `setUp()`/`tearDown()`, always call `super().setUp()` early in your `setUp()` method and `super().tearDown()` late in your `tearDown()` method to preserve SeleniumBase's default behavior. For example: `super().setUp()` then your custom code, and then your custom teardown code then `super().tearDown()`.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'seleniumbase'
The SeleniumBase Python package is not installed in the current Python environment.
fix
Run `pip install seleniumbase` in your terminal to install the library.
WebDriverException: Message: 'chromedriver' executable needs to be in PATH.
The required WebDriver executable (e.g., Chromedriver for Chrome) is not found in your system's PATH, or SeleniumBase could not automatically download and configure it.
fix
Run `seleniumbase install chromedriver` in your terminal to let SeleniumBase manage the driver, or manually place the driver executable in a directory that is part of your system's PATH.
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element:
The web element specified by the locator could not be found on the page at the time the command was executed, often due to an incorrect locator, the element not yet being present, or the page not fully loading.
fix
Verify the element's locator using browser developer tools, ensure there is a sufficient wait time (e.g., `self.wait_for_element()` or `self.assert_element()`) before attempting to interact with the element, or re-evaluate the navigation flow.
ImportError: cannot import name 'BaseCase' from 'seleniumbase.core.base_case'
The import path for the `BaseCase` class has changed in recent versions of SeleniumBase.
fix
Update your import statement to `from seleniumbase.sb_test_case import BaseCase`.
Upgrade
Version history
4.52.4latest on PyPI · released Aug 25, 2026
Audit
Dependencies
pythonrequiredRequired Python version.
seleniumrequiredCore dependency for browser automation.
pytestrequiredIntegrated test runner framework, often used for organizing tests.
allure-pytestoptionalOptional dependency for generating Allure Reports. No longer bundled by default.
Agent activity
12 hits · last 30 days
node
10
OpenAI (training)
1
Resources