Jon Leighton

Poltergeist: A PhantomJS driver for Capybara

This announcement is coming way later than I had originally intended. Last October I started experimenting with the idea of writing a driver for Capybara that would use PhantomJS as the browser.

Initially the biggest problem was addressing the issue of how to communicate between a Ruby process and a PhantomJS process. But then it hit me: PhantomJS gives you a browser environment, so you can do everything you can do in a browser, and you can do Web Sockets in a browser. So I used Web Sockets.

After hacking away for a while I eventually had a pretty complete driver. But I was being plagued by segfaults that were coming from WebKit’s JavaScriptCore JS engine. Thus began months of poking C++ code and getting far too comfortable with gdb.

I tried the Qt 4.8 RC (it has since been properly released) and found that the JSC segfault had gone, but now there was a new segfault. After much hair-pulling I found a workaround. But I was still left with another problem: it wasn’t possible to attach files to <input> elements against Qt 4.8. After yet more hair-pulling I found the culprit for that one, too.

Which leads me to the point where I am now finally happy to invite you, dear reader, to try out my humble little Capybara driver. Let me know how you get on!

3 January 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.

Comments