For a long time, I’ve been a fan of Watir, a Ruby library that basically drives a web browser (Firefox usually, but you can substitute Safari or Chrome if you prefer). Well, here’s where it gets even more awesome. Watir now uses WebDriver, a protocol to talk to the browser that has been spun out of Selenium.
And PhantomJS implements the WebDriver protocol.
Here’s the install instructions for OSX
I got it running on my Ubuntu server. I just had to download the PhantomJS binary, copy it into /usr/local/bin/, install the watir-webdriver gem, install the libfontconfig package with Aptitude and boot up PhantomJS manually using