Alternative Uses for GhostDriver and Headless Browser testing

I’ve been using GhostDriver recently.

I could never get along with HTTPUnit driver, it so rarely worked for me. But GhostDriver has been magnificent.

Whenever I want to do any headless browser testing I use GhostDriver.

I blogged about my use of GhostDriver to test www to mobile site redirection, over on

I’ve also been using it as part of a “Tester’s Link Checker” I’ve been experimenting with.

I use it because it is easy to add to my project.


And I just make sure I download the PhantomJS executable as well. I’ve been adding it into a tools sub folder of my project that I don’t check in to version control.

    public static final File PHANTOMJS_EXE =
            new File(System.getProperty("user.dir"), 

Then I create the driver pointing to the executable:

    DesiredCapabilities caps = new DesiredCapabilities();

    PhantomJSDriver driver = new PhantomJSDriver(caps);

PhantomJS and GhostDriver have been working flawlessly for me.

What I love about it, is that it is so easy to change the user-agent

caps.setCapability("", agent);

Coupled with the WebDriver ability to set browser sizes:

driver.manage().window().setSize(new Dimension(320, 480));

I’ve been happily crawling web sites with different user-agents and setting the screen size to the correct size so I can harvest a bunch of screenshots which show me an approximation of the responsiveness of the site’s HTML.

The link checker code isn’t ready for release, but if you want a simple example of how I’ve been using GhostDriver to test mobile site redirection by controlling the user-agent then you could head off to github and see the code.


This entry was posted in Selenium Simplified Blog, WebDriver. Bookmark the permalink.

One Response to Alternative Uses for GhostDriver and Headless Browser testing

  1. Roman says:

    There is a great tool that maybe you are not familiar with – Screenster ( It is a test automation tool and 10 times more productive than any other tool, working on the cloud and codeless.

Leave a Reply

Your email address will not be published. Required fields are marked *