In order to set up headless tests on RHEL 6.7, you will need Xvfb, which is a virtual framebuffer that performs the graphical operations without showing anything on the screen. The browser that I chose to use for my headless tests was Firefox. In order to install Xvfb on RHEL use yum:
yum install xorg-x11-server-Xvfb
If this command does not work or is outdated, simply use yum search:
yum search xvfb
Then install the package that the yum search command returns. Once you have Xvfb installed, you can install Firefox by using yum, as well:
yum install firefox
The next thing you need to do is make sure Xvfb and Firefox can, and know how to communicate to each other. There are a couple things that you need to do, the first being to make sure your “/etc/hosts” file is correct. In order for the two to communicate to each other, you need to make sure the following line is the leading line of your “/etc/hosts” file:
127.0.0.1 localhost
It is very important that this is the first entry. For example, if your “/etc/hosts” file has something like this:
127.0.0.1 localhost.localdomain localhost
Your headless tests will NOT work. The next thing you need to do before starting Xvfb is set the display for Firefox, which can be easily done as a system variable:
export DISPLAY=:99
This line will tell Firefox to open up on display :99.
Tip: if you do not want to set this variable every time you login, you can add the command to the end of your “/etc/profile” file.
The next thing we want to do is start the Xvfb server with the SAME DISPLAY NUMBER we chose for Firefox to run on. The easiest way this is done run the command: /path/where/it/is/installed/Xvfb :99'
This will simply start the Xvfb server on the display :99. There are a lot of other flags that can be set, just check the ‘man’ page.
Once the Xvfb server is started, all you have to do is run your Selenium tests and they are now headless!
Setting Up Headless Selenium Tests On RHEL 6.7
Coveros Staff
October 4, 2015
Related Blogs
The ROI of Training
This article builds the financial case for investing in staff training, covering both hard metrics and intangible cultural benefits such as...
Ensuring Control Compliance and Accountability with the GitHub Well Architected Framework
A deep dive into the Governance pillar of the GitHub Well-Architected Framework, covering auditability, accountability, adaptability, and...
Bolstering Your Defenses with the GitHub Well-Architected Framework
Breaks down the Application Security pillar of the GitHub Well-Architected Framework, linking principles, checklists, and implementation...
Fostering Collaboration with the GitHub Well-Architected Framework
A deep dive into the Collaboration pillar of the GitHub Well-Architected Framework, covering principles, checklist criteria, and practical...
Coveros Staff
This post represents the collective insights of the Coveros team. Our staff consists of software experts who bring deep experience in secure agile development, DevOps, testing, and software quality. Over the past 20 years, Coveros has trained more than 30,000 professionals and worked with half of the Fortune 100 companies on mission-critical software development challenges. We draw on this extensive experience to share practical insights, proven strategies, and real-world solutions that help organizations build better software faster and more securely.