From zero to tested with Centos7, Chrome and Selenium

16 Jan 2015 | By Matt Robbins | Tags testing centos selenium chrome headless

If you are restricted to Centos in your CI environments and you need to run browser tests previous solutions include running in PhantomJS, an old version of Firefox under Xvfb or farming out to a Selenium Grid.

With Centos7 you now have another option as Chrome is fully supported on this OS.

You can easily run a headless (ish…Xvfb) Chrome browser.

Here I show you the bare minimum required to get from nothing to a working example.

Once you have it working you would need to consider repeatability e.g. provisioning the environment via something like Puppet, spinning it up in a Docker container or maybe just a simple script.

Grab a Centos 7 VM

vagrant init matyunin/centos # a good community base image at time of writing
vagrant up
vagrant ssh

As root

Add google yum repo

cat << EOF > /etc/yum.repos.d/google-chrome.repo
name=google-chrome - \$basearch

As vagrant

Install dependencies

sudo yum install -y ruby ruby-devel gcc xorg-x11-server-Xvfb google-chrome-stable
gem install selenium-webdriver headless
version=`curl -s`
curl -s "$version/" >
unzip && sudo mv chromedriver /usr/local/bin/

Create test script

cat << EOF > test.rb
require 'rubygems'
require 'headless'
require 'selenium-webdriver'
headless =
driver = Selenium::WebDriver.for :chrome ''
puts driver.title

Run test

ruby test.rb


blog comments powered by Disqus