I’ll admit right up front that I don’t really understand the point of doing browser automation in a browser-that-doesn’t-have-a-browser. Especially since its kinda the point to light up browsers that your customers actually use. Yes, I know it is ridiculously fast. And yes, I understand the spooky WebKit monoculture that is starting to form, but so far I have yet to meet anyone who surfs the web with a headless browser.

I firmly believe you should be bucketing your scripts into at least two distinct categories; ‘shallow’ are the ones that absolutely must be run on each build and ‘deep’ is everything else. Even in a large application there is only going to be maybe a dozen ‘shallow’ scripts that get executed so be ruthless in your segmentation.

It is these ‘shallow’ scripts that are a good candidate to run in a headless browser since you want the feedback loop as tight as possible since they are running on each commit/push. Which is why as of about 10 minutes ago Saunter has support for GhostDriver which is a WebDriver implementation inside PhantomJS — a QT/WebKit/Headless browser.

Configuring up Saunter to use PhantomJS is pretty simple. First you need to have the GhostDriver server running on the host you want. Similar to the Android WebDriver implementation, the GhostDriver implementation lives outside of the Se Server and listens on its own port.

  1. Download PhantomJS
  2. Start GhostDriver on whatever port you like; I’ll use 5555 as an example ```
    phantomjs --webdriver=5555
     ```
    
    

Once that is running its just a matter of telling Saunter via its config file where the server lives and that you want to use GhostDriver.

SaunterPHP – conf/saunter.inc

<pre lang="php">$GLOBALS['settings']['browser'] = "phantomjs";
$GLOBALS['settings']['seleniumserver'] = "localhost";
$GLOBALS['settings']['seleniumport'] = 5555;

Py.Saunter – conf/saunter.ini

<pre lang="ini">[Selenium]
server_host: localhost
server_port: 5555
browser: phantomjs

I would be really leery of relying on PhantomJS for all my scripts, but I can see how it can use a useful part of a larger Continuous Delivery flow — which is why it has appeared as an option.