Running Headless Selenium on a Raspberry Pi

I wanted to run Selenium WebDriver headlessly on a Raspberry Pi for a project of mine (not related to automated testing). Here’s what I did:

1. Install Ruby. In my case, the version didn’t matter, so I installed it lazily with sudo apt-get install ruby. Note that the repo’s Ruby is a bit old (1.9.1), so you should use RVM if the version matters.

2.Install Mozilla Iceweasel, Debian’s rebranded version of Mozilla Firefox. Make sure to apt-get update and upgrade; the Iceweasel install didn’t work for me until I did.

sudo apt-get update
sudo apt-get upgrade
sudo apt-get install iceweasel

3. Install Xvfb, which is a virtual framebuffer that lets you run stuff like Iceweasel headlessly.

sudo apt-get install xvfb

4.Get the gems you need:

sudo gem install selenium-webdriver
sudo gem install headless # Ruby wrapper for Xvfb

5. Disable ipv6 on the Pi. To do this you’ll need to modify two files. Modify /etc/modprobe.d/ipv6.conf:

plain /etc/modprobe.d/ipv6.conf
# Don't load ipv6 by default
alias net-pf-10 off
alias ipv6 off

and modify /etc/hosts:

/etc/hosts       localhost
#::1            localhost ip6-localhost ip6-loopback
#fe00::0                ip6-localnet
#ff00::0                ip6-mcastprefix
#ff02::1                ip6-allnodes
#ff02::2                ip6-allrouters       raspberrypi

6. At this point, everything should “just work.” Write a quick script and test it out!

require 'selenium-webdriver'
require 'headless'

headless =

driver = Selenium::WebDriver.for :firefox ''
puts driver.title