Thursday, March 29, 2012

Headless gem


The headless gem is a ruby wrapper for Xvfb, the virtual frame buffer.Virtual frame buffers are used to run graphical software on a “headless”, i.e. display-less, server.Headless gem makes it possible to create and release frame buffers straight from Ruby code. 

This gem makes it easy to run graphical applications (such as real web browsers) on a headless Linux machine. 

Command to install this gem:

gem install headless

An Example:

require 'watir-webdriver'
require 'headless'
headless = Headless.new
headless.start
b = Watir::Browser.start 'www.google.com'
puts b.title
b.close
headless.destroy

Finally, running WebDriver headless tests requires you to run a Selenium Server, which is additional overhead for your tests.


But why headless?


Whilst running automated browser tests in a headless form can speed things up, the main reason,  people wanting headless watir-web driver support is so that tests can be run on headless Linux machines, for example, a Jenkins Server.

No comments:

Post a Comment