Glad You're Ready. Let's Get Started!

Let us know how we can contact you.

Thank you!

We'll respond shortly.

Capybara, Selenium, Webkit and your Mobile Site

Your app now has mobile-friendly views. Do they have any Webkit-specific functionality that you want to test in-browser? Or rather, why are you testing your mobile views in desktop Firefox? Is it because Capybara/Selenium support for Webkit browsers was sketchy? Worry no more. Chrome 12, Capybara 1.0, and Selenium 2 are your new best friends.

So install Chrome, make sure your Gemfile has Capybara set to >= 1.0, bundle install and let’s get configuring.

Update your SpecHelper

You have to tell Capybara that you want to use Selenium/Webdriver and Chrome. Put this in your spec_helper.rb file

Capybara.register_driver :selenium_chrome do |app|, :browser => :chrome)

Chrome & chromedriver

While there’s been limited Selenium support in Chrome for a while, with release 12 there is an entirely new and complete automation interface to Chrome. To use it you need a platform-specifc chromedriver binary in order to connect Webdriver and Chrome. Download it, make sure it’s executable, and put it on your path.

Chrome likes to update, so stay on the general release (if you can) to reduce update frequency. You can even take steps to prevent Chrome from updating, but I’ll leave that as an exercise for the reader.


That should be enough to get your Capybara specs to start using Chrome. You’ll want to play with your setup and maybe only run some specs with this driver.


Webdriver does not appear to support Safari. This may matter to you if you’re using this setup to approximate Mobile Safari. But for the types of tests you’re likely writing for Selenium it should be good enough. After all, every mobile Webkit build is slightly different.

While complete (in terms of browser features) and far faster than previous Selenium-Chrome pairings, it’s still slow-ish – for example, typing isn’t nearly as fast as Firefox. So you might not want to make this your default stack for your entire Rails app.

You might make it your only stack if you’re testing a Webkit & JavaScript only framework, say an HP webOS application using Enyo.

But that’s another post.

  1. wizztjh says:

    nice to know that chrome and capybara is working now! thanks

  2. Jari says:

    The chromedriver download link is a bit outdated. Future releases will be published here:

    It’s also worth mentioning WebDriver’s Android and iPhone drivers, which allow you to run your tests on both simulators and actual devices:

Post a Comment

Your Information (Name required. Email address will not be displayed with comment.)

* Copy This Password *

* Type Or Paste Password Here *