Tested on:RPi3; Raspbian Stretch; Python3
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)

Python3: Browser tests on a Raspberry Pi with Firefox, Virtualdisplay, Selenium and PyTest

A modern website is more than some HTML plus content. Content Management Systems (CMS) use a great number of complex technologies like MySQL, CSS, PHP and Python. With growing complexity, maintenance effort rises. A way to increase maintainability are browser tests for automatically simulating and validating website interactions. It’s entirely possible to run browsertests solely on a Raspberry Pi with Firefox, Selenium and PyTest. With Virtualdisplay, not even a display for the Raspberry Pi is required (headless).

First, install the required components with

Then, you need to install the Gecko driver for Arm7:

DuckDuckGo browser test
Now, a demonstration of a browser test for validating the DuckDuckGo search engine. First, download the demo script from Github:

Ensure that Apache isn’t running on your system with

Then start the script:

The script loads duckduckgo.com, enters the title of a tutorial and outputs an exception, if there’s no hit for Knight of Pi.
Have a look at Techbeamer for more info on writing browser tests with Selenium in Python.

Code details
This creates a virtual display first and then a web driver using a profile of the RPi-compatible browser Firefox:

The driver loads the DuckDuckGo homepage. Then, the search bar element is accessed and and a search for a tutorial title is submitted.

Now, the results are being collected. assert ... ensures that at least one hit for Knight of Pi is found.

Browser tests in a local network
Browser tests can be run on the internet or in a local network. For running them locally, a server like Apache needs to be installed. The Tutorial Local clone of a WordPress blog shows how to setup Apache locally on a Raspberry Pi.
For performing local browser tests, open the script browser_test.py and replace the line


The subsequent browser test designed for DuckDuckGo fails obviously.

Full script
Click on Full Script to show all of the code.

Techbeamer Selenium Python Browsertests: http://www.techbeamers.com/selenium-webdriver-python-tutorial/
Selenium Website: http://docs.seleniumhq.org
Software Test Setup: http://www.knight-of-pi.org/python-project-setup-test-driven-development/
Local clone of a WordPress blog with Duplicator: http://www.knight-of-pi.org/running-a-wordpress-blog-locally-on-a-raspberry-pi-with-wp-duplicator/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


  1. Thank you! I really appreciate this. I am new to both Python and Raspberry PI. I think I’ve invested like 15-20 hours trying out different solutions for a simple web scraper for my Raspberry. It has been a frustrating journey since it took me like an hour to write a working program on my MAC. I have been diving deep into the rabbit hole and tried everything from Chromedriver, different versions of Geckodriver to PhantomJS… and requests-html and so forth.

    • Thanks for the warm words! If i saved you some time and you’re feeling generous, you could send me some via PayPal.
      Anyways, happy hacking!

  2. Thanks so much for this write-up, it’s the *only* comprehensive and accurate guide I could find for running Selenium on a Raspberry Pi.


Time limit is exhausted. Please reload CAPTCHA.