Member-only story

Running Selenium WebDriver tests using Firefox headless mode on Ubuntu

Grig Gheorghiu
3 min readJan 7, 2016

--

Selenium IDE is a very good tool for recording and troubleshooting Selenium tests, but you are limited to clicking around in a GUI. For a better testing workflow, including load testing, you need to use Selenium WebDriver, which can programatically drive a browser and run Selenium test cases.

In its default mode, WebDriver will launch a browser and run the test scripts in the browser, then exit. If you like to work exclusively from the command line, then you need to look into running the browser in headless mode. Fortunately, this is easy to do with Firefox on Ubuntu. Here’s what you need to do:

Install the official Firefox Beta PPA

$ sudo apt-add-repository ppa:mozillateam/firefox-next

(this will add the file /etc/apt/sources.list.d/mozillateam-firefox-next-trusty.list and also fetch the PPA’s key, which enables your Ubuntu system to verify that the packages in the PPA have not been interfered with since they were built)

Run apt-get update

$ sudo apt-get update

Install firefox and xvfb (the X windows virtual framebuffer) packages

$ sudo apt-get install firefox xvfb

Run Xvfb in the background and specify a display number (10 in my example)

$ Xvfb :10 -ac &

Set the DISPLAY variable to the number you chose

--

--

Grig Gheorghiu
Grig Gheorghiu

Written by Grig Gheorghiu

DevOps, cloud computing, Python and Golang programming, data science, automated testing.

Responses (10)