From zero to tested with Centos7, Chrome and Selenium
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
[google-chrome]
name=google-chrome - \$basearch
baseurl=http://dl.google.com/linux/chrome/rpm/stable/\$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
EOF
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 http://chromedriver.storage.googleapis.com/LATEST_RELEASE`
curl -s "http://chromedriver.storage.googleapis.com/$version/chromedriver_linux64.zip" > chromedriver.zip
unzip chromedriver.zip && sudo mv chromedriver /usr/local/bin/
Create test script
cat << EOF > test.rb
require 'rubygems'
require 'headless'
require 'selenium-webdriver'
headless = Headless.new
headless.start
driver = Selenium::WebDriver.for :chrome
driver.navigate.to 'http://google.com'
puts driver.title
headless.destroy
EOF
Run test
ruby test.rb