How to run Selenium headless Firefox in Ubuntu

This tutorial will show you how to run Selenium headless Firefox in Ubuntu.

What is selenium?
Selenium automates browsers. Primarily, it is used for automating web applications for testing purposes, but is certainly not limited to just that. Boring web-based administration tasks can be automated as well.

In other words although it is an automated web testing framework,it can also be used for purposes other than testing .When we run firefox on server it has no display to show data or content, so with the help of xvfb: ( X-Virtual Frame Buffer ) and Selenium server standalone we can create display virtually and use or extract data virtually. (Ex : Login and Extract data).

Below the points to follow for run Selenium headless Firefox in Ubuntu,

Install Java :

sudo apt-get install openjdk-7-jdk

Download selenium standalone server : Find latest selenium standalone version from


Install/Update firefox :

  • Install : For installing new firefox

sudo apt-get install firefox

  • Update : For update firefox new version

sudo add-apt-repository ppa:ubuntu-mozilla-security/ppa

sudo apt-get update

sudo apt-get install firefox

Install xvfb : ( X-Virtual Frame Buffer )

sudo apt-get install xvfb

Start XVFB server :

sudo nohup Xvfb :40 -ac &

(instead of 40 any number & for verify check ‘.X40-lock’ which has been created inside /tmp folder. It will show up when we do (ls -a) list all the files)

export DISPLAY=:40

sudo su

nohup java -jar selenium-server-standalone-2.44.0.jar &

now script is ready to run on headless Firefox.

Hope this tutorial will help you to run script on headless firefox.

To know more on selenium visit


Table of Contents

Related posts