Monday, January 23, 2012

Cucumber, Capybara, and Webkit testing for Ajaxified actions

I recently upgraded my testing stack and now use Capybara and Webkit with Cucumber (and RSpec, too). I ran into a number of problems and found this post by Mathew O'Riordan incredibly helpful. He tracks the history of his research and testing through a github project and at various points on the blog entry shows the commit for the changes he just discussed: kudos on that approach!

A couple of gotchas that I ran into along the way:

First, you may need to add the following line to your features/support/env.rb file:
require 'capybara-webkit'
O'Riordan doesn't do this in his project, but I got an error:
"no driver called :webkit was found, available drivers: :rack_test, :selenium (Capybara::DriverNotFoundError)"
and found this discussion which gave me the solution.

Second, although it may be obvious, I missed the fact that you MUST put
before each scenario that requires in-browser javascript. I had thought this was just a way of grouping scenarios together, but it actually triggers the use of the webkit driver to run the step.

No comments:

Post a Comment