RaspberryPi – selenium nightmares.

I was recently trying to run a selenium script for this startup/project of mine. And guess what.. it was a nightmare. Outdated Repositories, confusing requirements, virtual displays, more outdated/non-supported repos, architecture miss-match and much more shit.

After a day of brainf*ing I finally figured this out so I decided to make a post about it because why not? giving back to community{lol}.

Here’s how to setup selenium on your raspberry pi in 2019 :

Setting up PI (headless method):

  • Download latest raspbian version and Etcher.
  • Using etcher burn the raspbian image onto a 16Gb+ sdCard.
  • After the image writing is complete open the root directory.
  • Create a new blank file named ssh (without extension).
  • Create a file named wpa_supplicant.conf and add the following to it :
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

  • Done. Eject SD Card and shove it into the pi.
  • Boot the pi and use a network monitor(my fav. is fing) to find out the local ip address of pi.
  • SHH into the pi using ssh pi@<ipAddress> command.
  • Update the repositories using sudo apt-get update .

Installing required repositories :

It is very crucial to download the versions of repos I specifically mention because some of them are out of support ,some are built for different architectures and some are not cross compatible.

sudo apt-get install iceweasel

sudo apt-get install xvfb

sudo apt-get install xserver-xephyr

sudo pip3 install selenium==2.53.6

sudo pip3 install pyvirtualdisplay

sudo pip3 install pytest

wget https://github.com/mozilla/geckodriver/releases/download/v0.19.1/geckodriver-v0.19.1-arm7hf.tar.gz

tar -xf geckodriver-v0.19.1-arm7hf.tar.gz

rm geckodriver-v0.19.1-arm7hf.tar.gz

sudo chmod a+x geckodriver

sudo mv geckodriver /usr/local/bin/

Sample test program :

from selenium import webdriver
from pyvirtualdisplay import Display

display = Display(visible=0, size=(800, 600))

profile = webdriver.FirefoxProfile()
driver = webdriver.Firefox(profile)