Splinter – Web Testing Tool

Splinter is an open source tool for testing web applications using Python. Splinter provides easy to use functions to access the elements in a web page. We use Splinter for testing web applications involving user flows.

Splinter’s Easy to use APIs

Simple APIs – Splinter provides simple APIs to visit URLs and access elements in the web page. browser.visit(“https://saisyam.com”) will load the web page in the default driver, Firefox. Below are some of the functions that will help in accessing elements in the page:

browser.find_by_text('Hello World!')

Multiple Driver Support – Supports multiple web drivers, along with Flask and Django. We can test Flask or Django applications using Splinter. Below is a simple example of using Flask driver:

from flask import Flask
app = Flask(__name__)

def index():
    return 'Hello, World!'

def page_not_found(e):
    return 'Oops! 404', 404

from splinter import Browser

browser = Browser("flask", app=app)
assert "Hello, World!" == browser.html

assert "Oops! 404" == browser.html

Filling forms – filling forms made easy in Splinter with browser.fill() API.

Simple example using Splinter

from splinter import Browser

url = "https://saisyam.com"
browser = Browser()
assert browser.title == "Saisyam – Personal Blog"

The above example simply loads my website and check the title. The default web driver is Firefox. If we want to use other drivers like, chrome, we will pass it as an argument to the Browser class as Browser(“chrome”). We can pass chrome options to the Browser class with options variable as Browser(“chrome”, options=chrome_options) where chrome_options is webdriver.ChromeOptions().

Accessing Web driver object

Splinter’s Browser class wraps the web driver object. You can access the driver object through browser.driver. We saw few issues with Splinter screenshot APIs (browser.screenshot) like, Splinter was adding a random string at the end of the provided file name and the screenshot captured was not complete. We used driver’s default screenshot API (driver.save_screenshot) as a work around. Our tests mostly run on Servers deployed on cloud services like AWS. It seems Splinter screenshot API has some issues with driver’s headless mode and not working on server environments. My Github repo web-automation-testing provides examples on using Splinter with various drivers and options.


Splinter makes testing web applications easier with least learning curve and less code. With few work arounds and tweaks as mentioned above, we were able to get the best out of it. Try it and provide your comments. Thanks for reading.


  1. Pingback: Automation testing of web application with fake webcam - Saisyam

  2. Pingback: Using Splinter in headless mode on Linux Servers - Saisyam

Leave a Reply

Your email address will not be published. Required fields are marked *