Jon Leighton

Poltergeist 1.0!

Almost a year ago, on a complete whim, I decided to try to hook up the headless browser PhantomJS with Ruby’s full-stack acceptance testing framework, Capybara.

After some furious prototyping I decided that the idea was a goer, but my initial progress towards a usable driver was dogged by segfaults and oddities coming from within WebKit.

If I’d known it was going to be such hard work then I probably wouldn’t have started, but after having written lots of code I wasn’t willing to give up. So I started learning about C++ and poking around the WebKit source code until I managed to solve my problems. Probably the biggest change I made was to implement proper handling of Javascript exceptions - before this, any error generated inside PhantomJS would be a mystery, since there was no stack trace to follow.

In January, I finally announced to project and started encouraging people to give it a try. Some time soon after we switch the Loco2 codebase onto it, pretty much halving our test time compared to Selenium. This provided some invaluable real-world feedback to help iron out bugs.

Since then, many many bugs have been fixed, and the user base has grown. The community around PhantomJS has also grown, and this has been a great benefit to Poltergeist because other people have been adding features to PhantomJS that we can then make use of.

Over the months I’ve seen lots of tweets from people who are using Poltergeist and liking it. This is probably my favourite thing about the project: just hearing about people’s successes feels awesome.

But the work isn’t over. Not everybody has a pain-free time. PhantomJS does sometimes crash, and I’m sure there are still bugs lurking in the Poltergeist codebase.

My aim from the start has always been to make Poltergeist the driver that fails as helpfully as possible.

I pretty much believe that full-stack testing will always be difficult and somewhat painful. I will continue trying to deal with bugs as much as possible, but I also place a great deal of value on having clear, helpful error messages and debugging aids. This is why I put effort into sorting out Javascript errors in PhantomJS, and adding remote web inspector support to Poltergeist.

One thing I should have done a long time ago is provide good documentation about troubleshooting. This also comes under the remit of failing helpfully, and so I’ve finally done that.

Thanks to everyone who has given Poltergeist a try, and especially to those who have contributed code. Tell all your friends, let’s make this thing even better!

7 October 2012

Jon Leighton is an experienced software engineer, specialising in Ruby. He is based in the beautiful mountains of Snowdonia in North Wales, and is particularly interested in projects with a social purpose. Do get in touch if you'd like to chat.