PhantomJS/GhostDriver support arrives in Saunter

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/

$GLOBALS['settings']['browser'] = "phantomjs";
$GLOBALS['settings']['seleniumserver'] = "localhost";
$GLOBALS['settings']['seleniumport'] = 5555;

Py.Saunter – conf/saunter.ini

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.

Comments 1

  1. mam-p wrote:

    This is SERIOUSLY cool news as one of the dev managers at work was sounding wistful about me trying out PhantomJS/GhostDriver just a few days ago!

    Is a particular version of py.saunter required to make the above work?

    Could you possibly devote a future post to the dangers of relying too much on this form of browser testing? The manager who asked me about it definitely had more in mind than just “shallow” tests….

    Posted 26 Apr 2013 at 12:23 am

Post a Comment

Your email is never published nor shared. Required fields are marked *