Registry / testing / splinter

splinter

JSON →
library0.21.0pypypi✓ verified 85d ago

Splinter is a Python library that provides a high-level browser abstraction for web acceptance testing and browser automation. It supports multiple drivers including Selenium (for Chrome, Firefox, Edge, etc.) and offers a consistent API to interact with web elements, forms, and pages. It is actively maintained with regular feature releases and bug fixes, typically every few months. The current stable version is 0.21.0.

pip install splinter
INSTALL
IMPORT
SIG · SPLINTER
S
splinter
testingpythonv0.21.0
Install
1.7s avg
Import
251ms
Disk
17MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v0.21.0 · 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.960 runs
installs and imports cleanly · install 0.0s · import 0.260s · 19.1MB
glibc
py 3.103.960 runs
installs and imports cleanly · install 1.7s · import 0.241s · 20MB
17MB installed
● package 17MB
Code
Verified usage

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

Browser
from splinter import Browser

This quickstart demonstrates how to initialize a headless Chrome browser, navigate to a URL, fill out a login form, click a button, and assert text presence. It includes error handling and ensures the browser is closed properly. For Chrome/Firefox, ensure the respective driver (e.g., chromedriver, geckodriver) is in your system's PATH or managed by a tool like `webdriver-manager`.

from splinter import Browser import os # Optional: Use webdriver-manager to automatically download/manage drivers # from webdriver_manager.chrome import ChromeDriverManager # driver_path = ChromeDriverManager().install() # Create a Browser instance # Common options: 'chrome', 'firefox', 'edge' # headless=True is recommended for CI/CD or background tasks browser = Browser('chrome', headless=True) # Or 'firefox', 'edge', etc. try: browser.visit('http://quotes.toscrape.com/login') print(f"Visiting: {browser.url}") browser.fill('username', 'admin') browser.fill('password', 'password') browser.find_by_css('input[type="submit"]').click() if browser.is_text_present('Logged in!'): print(f"Successfully logged in. Current URL: {browser.url}") browser.click_link_by_text('Logout') assert browser.is_text_present('Login') print("Successfully logged out.") else: print("Login failed.") except Exception as e: print(f"An error occurred during the test: {e}") finally: if browser: browser.quit() # Always close the browser
Debug
Known issues
breakingPython 2.7 support was removed. Splinter v0.17.0 and later only support Python 3.
fix
Ensure your project runs on Python 3.x.
affects: >=0.17.0
breakingSelenium 3 is no longer installed by default since v0.17.0. Users must explicitly install either `splinter[selenium3]` or `splinter[selenium4]` (recommended).
fix
Update your `pip install` command to include the desired Selenium extra, e.g., `pip install splinter[selenium4]`.
affects: >=0.17.0
deprecatedThe methods `WebDriver.is_element_not_visible_by_css` and `WebDriver.is_element_visible_by_css` were deprecated in favor of `WebDriverElement.is_visible()` and `WebDriverElement.is_not_visible()`.
fix
Replace calls to the deprecated methods with `element.is_visible()` or `element.is_not_visible()` on the `WebDriverElement` object.
affects: >=0.19.0
gotchaCalling `CookieManager.delete()` without any arguments now deletes *all* cookies. Prior to v0.19.0, its behavior when called without arguments might have been different or unclear.
fix
Be aware of the new default behavior. If you intend to delete specific cookies, ensure you pass the relevant arguments to `delete()`.
affects: >=0.19.0
gotchaCompatibility issues can arise from mismatched Splinter and Selenium versions. For example, Splinter v0.16.0 pinned Selenium < 4.0, while v0.17.0 added Selenium 4 support.
fix
Always install Splinter with the appropriate Selenium extra (`splinter[selenium3]` or `splinter[selenium4]`) and ensure your `selenium` package version is compatible with your Splinter version. If using `webdriver-manager`, ensure it's up to date.
affects: 0.16.0-0.17.0
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'selenium'
Splinter was installed without the necessary `selenium` dependency. Since v0.17.0, `selenium` is no longer installed by default.
fix
Install Splinter with the appropriate Selenium extra: `pip install splinter[selenium4]` (recommended) or `pip install splinter[selenium3]`.
WebDriverException: Message: 'geckodriver' executable needs to be in PATH.
The browser driver executable (e.g., `geckodriver` for Firefox, `chromedriver` for Chrome, `msedgedriver` for Edge) is not found in your system's PATH.
fix
Download the correct driver for your browser version and operating system, then either place it in a directory listed in your system's PATH, or provide its path explicitly during browser initialization. Alternatively, use `webdriver-manager` to automate this: `pip install webdriver-manager` and then `from webdriver_manager.chrome import ChromeDriverManager; driver_path = ChromeDriverManager().install()`.
AttributeError: 'WebDriver' object has no attribute 'find_by_css' (or similar method)
You might be attempting to call Splinter methods directly on the underlying `selenium.webdriver` object instead of the `splinter.Browser` instance, or you're using a method that doesn't exist in your installed Splinter version.
fix
Ensure you are using the `splinter.Browser` object (e.g., `browser.find_by_css(...)`) for Splinter's API. If the method still doesn't exist, check the official Splinter documentation for its availability in your version.
selenium.common.exceptions.SessionNotCreatedException: Message: session not created: This version of ChromeDriver only supports Chrome version XX
There is a mismatch between the version of your Chrome browser and the version of ChromeDriver installed/used.
fix
Update your ChromeDriver executable to match your installed Chrome browser version. Using `webdriver_manager.chrome.ChromeDriverManager().install()` (or similar for other browsers) is the easiest way to keep drivers automatically updated.
Upgrade
Version history
0.21.0latest on PyPI · released Jan 16, 2024
Audit
Dependencies
seleniumrequiredRequired for most real browser automation drivers (e.g., Chrome, Firefox). Not a direct 'install_requires' dependency since v0.17.0; must be installed via extras or separately.
webdriver-manageroptionalHighly recommended for automatically downloading and managing browser drivers (e.g., chromedriver, geckodriver).
Agent activity
18 hits · last 30 days
node
14
OpenAI (training)
1
Resources