GhostDriver 1.1.0: codename "Banquo"

  • ghostdriver • phantomjs • release • changes • info • banquo
  • 769 words

It’s long overdue. Last time I have cut a release of GhostDriver (1.0.4) was… July 2013. And blogged about it only in August!!! I gotta take a look at my GitHub commits over the 2013: something tells me that year-in-commits nicely overlaps with my eventful 2013. But let’s try to stay on topic.

So, GhostDriver 1.1.0, codename “Banquo”. This time the codename was picked by my wife - fitting, given how important she has become this year for Leonardo and Me.

I know, I keep going off topic. Sorry…

As I’m writing, this new version hasn’t been imported into PhantomJS yet, but it will be very soon. Definitely before next release of PhantomJS. And please, don’t ask me about that - there is the PhantomJS Google Group for this kind of questions (I have just opened a discussion about this).

What’s new in 1.1.0

For a complete, up-to-date list of changes in the releases of GhostDriver, please DO take a look at the CHANGELOG.

Here is a cut&paste for 1.1.0:

  • ENHANCEMENT #293: Import Selenium 2.39.0 WebDriver Atoms
  • ENHANCEMENT: /maximize window will set the window size to 1336x768, currently most common resolution online (see statcounter)
  • ENHANCEMENT #275: Implemented Browser and Network (HAR) Logging types
  • FIXED #284: Attempt to wait for Page to Load if input causes form submit
  • FIXED #291: Throw exception when attempting to set invalid timeout value
  • FIXED #259: Fix issue regarding mouse clicks
  • ENHANCEMENT #290: Enabled support for “Keep Alive” HTTP connections
  • ENHANCEMENT #262: Allow access to PhantomJS API from WebDriver (Driver part)

As you might have noticed, I have highlighted 2 entries above…

Browser and Network (HAR) Logging

One difficulty of working with an headless browser is: there is no direct way to look at the browser and try to understand what it’s doing. It’s pretty much a black-box and debugging your tests against it might be hard.

Logging was already implemented, but the only way to grab the output was via standard output/error redirect. Not always suitable for the client-server architecture of WebDriver.

The WebDriver WireProtocol defines a set of API to access LOGs of different type. The logtype client is implemented by the binding. The driver should provide a view into the inner guts of the WebDriver implementation. The browser essentially is the console of the browser. The server… I’m not sure. In GhostDriver 1.1.0 we have added support for 2: browser and har.

HAR??? Yes, HAR - HTTP Archive. While I explained already the browser log-type, har will return a single-entry log, with the HAR of the current webpage, since the first load (it’s cleared at every unload event).

Support for the other logtypes might come in the future (the driver type should be simple enough).

A great THANK YOU goes to Dmitry Balabka (torinaki) and Wouter Groeneveld (wgroeneveld) for their key contributions. Keep it coming guys!

Access to PhantomJS API

This feature that has been requested SO MANY FREAKING TIMES!!!

PhantomJS has a rich set of API to control and tune the internal WebKit core. Access to the plethora of API that PhantomJS has was always high, since the beginning of the GhostDriver project.

While some see GhostDriver/PhantomJS as just a WebDriver implementation against a non-production browser, others see this as a way to easily control PhantomJS from another software. The issue was that the WebDriver Protocol is tuned for a specific scenario: emulate user interaction with a browser. PhantomJS is a bit less of a browser, and more of a scriptable browser engine. And it’s very useful in scenarios also not strictly related to testing and user interaction.

This API allows to send a string of JavaScript, written for PhantomJS, and be interpreted within the context of a WebDriver Page. In other words, for the given script the this variable is initialized to be the current Page.

The format of this WebDriver Protocol Extension:

HTTP POST /session/:id/phantom/execute
{
    "script"    : SCRIPT_SCRIPT
    "args"      : [ARRAY_OF_JS_BASIC_TYPES]
}

To see an example use of this API, check out this example.

This new API was entirely developed by Mark Watson (watsonmw), ex-colleague of mine at Neustar and awesome chap.

What do I have left to do

As I write this, I still have to finish up a couple of tasks to consider 1.1.0 fully released:

  • Commit 1.1.0 Java Bindings’s JAR to the Selenium repository DONE
  • Import 1.1.0 into PhantomJS DONE
  • Tag 1.1.0 on the repository DONE

I could have waited for those tasks to be complete… but I felt like this was overdue and I wanted to share a status report as soon as I could.

Also, it gives me closure for this blog post.