Home > Programming, QA, Test and Automation Stuffs > How to run Selenium Headless Browser in Ubuntu ?

How to run Selenium Headless Browser in Ubuntu ?

Hello again !!!

Today I will post a tutorial about how configure and run selenium headless in Ubuntu using Mozilla Firefox as your primary browser.

Install Firefox headless in Ubuntu

Download the latest version of Firefox on your PC. In case you don’t have firefox or using older version of firefox, follow the steps to upgrade firefox.

  • In /etc/apt/sources.list add the following line.
	ppa:mozillateam/firefox-stable
  • Run the following commands to upgrade or install latest version of Firefox to work with Selenium.
	sudo apt-get update
	sudo apt-get install firefox

Install Xvfb – the X Virtual FrameBuffer

This piece of software emulates the framebuffer using virtual memory which lets you run X-Server in machines with no display devices. This service is required to make browsers run normally by making them believe there is a display available. To install xvfb in ubuntu or Debian, run the following command:

sudo apt-get install xvfb

Now run the xvfb service in a display number which is less likely to clash even if you add a display at later stage. For this example, you can assume a display, 10.

sudo Xvfb :10 -ac

The parameter -ac makes xvfb run with access control off. The server should be running now.

Start browser headlessly in Ubuntu

Before you can run a browser, you need to set the environment variable DISPLAY with the display number at which xvfb is running. Before we add the environmental variable as a persistent one, let us check whether everything works as expected.

export DISPLAY=:10
firefox

If there was no error on the terminal, then you have successfully running firefox headlessly in Ubuntu. The command should keep running until you kill the process by pressing ctrl+ C or similar. There wont be any output.

Now that you have a browser running headless in Ubuntu server, you can run selenium server as you will run in your local machine.

Easy, don’t you think ? If you have any questions, just write below !

Thank you ! Have a good weekend !

 

Fonts: http://www.installationpage.com/selenium/how-to-run-selenium-headless-firefox-in-ubuntu/

Advertisements
  1. January 8, 2017 at 10:11 pm

    Howdy! I simply wish to offer you a huge thumbs up for your excellent info
    you have got right here on this post. I’ll be returning to your website for more soon.

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: