Using Splinter in headless mode on Linux Servers

How to run your Splinter automated test cases on a Linux server that does not have a UI? Most of my customers use cloud services from AWS, Google Cloud and Azure. They want to run automation from servers deployed on these cloud environments as part of their CI (Continuous Integration) pipeline. To achieve this we use Splinter in headless mode, in short, the Web driver will run the test in the background without opening the browser window.

Starting Splinter in Headless mode

Below is a simple Python example that open the browser in a headless mode and perform a test.

from splinter import Browser

url = ""

browser = Browser('chrome', headless=True)
assert browser.title == "Google"

The above code will open Chrome browser in the background, load the web page and test the assertion, in our case, compare the title of the page. The same works for Firefox as well

The above code was tested on Ubuntu 18.04 server.

Installing Chrome and Chromedriver in Ubuntu 18.04 server

Below are the instructions to install chrome and chrome driver on Ubuntu 18.04

$ sudo apt update
$ wget
$ sudo dpkg -i google-chrome-stable_current_amd64.deb

If your install fail with errors, then run the below commands:

$ sudo apt install -f
$ sudo apt update --fix-missing
$ sudo apt --fix-broken install
$ google-chrome --version
Google Chrome 75.0.3770.142

We have to download the same version of Google chrome driver as well.

$ wget
$ sudo apt install unzip
$ unzip

Make sure the extracted chromedriver is on the PATH. Now run the Python code.

Installing Firefox and Gecko driver on Ubuntu 18.04 server

Below are the commands to install Firefox and related Gecko driver on Ubuntu server.

$ sudo apt install firefox
$ wget
$ tar -xvf geckodriver-v0.24.0-linux64.tar.gz

Make sure geckodriver is on the PATH.


Definitely running Splinter in headless mode will take your automated test cases on to the cloud platforms, which will help in integrating your testing process into your DevOps. Sometimes you need to have more control on the test case execution, for example, recording the complete test execution. We need some more advanced tools like Virtual display, specifically Pyvirtuadisplay, which is a wrapper around Xvfb (X11 with frame buffer) to simulate UI. We will discuss this in future articles. Happy Coding!

Leave a Reply

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