Capybara::Rc

This gem provides an adapter that allows Selenium-RC-based code to execute using Capybara instead. This is useful because:

  • Selenium-RC has been deprecated for a while
  • Capybara allows your tests to run against different backends (not just selenium)
  • Porting an existing test suite to a new library is dangerous — you can wind up modifying your tests in such a way that they still pass but are no longer actually testing what you want.

Caveats

  • This is not a full adapter yet — it only adapts the methods that we are using at CDD.
  • Some things that were possible with Selenium-RC are not possible in Capybara. See DIFFERENCES.md for a list of some of these.

Installation

Add this line to your application's Gemfile:

gem 'capybara-rc'

And then execute:

$ bundle

Or install it yourself as:

$ gem install capybara-rc

Usage

  • Configure Capybara as is appropriate for your application
  • Replace your Selenium-RC initialization with something like this:
require 'capybara/rc'
# If @browser was your Selenium-RC browser before …
@browser = Capybara::Rc::Adapter.new(Capybara.current_session)

Additions

The ideal with this adapter is that you'd be able to drop it in and run your existing test suite with no changes. The reality is that you probably use some features of Selenium-RC that can't be adapted to Capybara (get_eval and the Selenium-RC in-browser JavaScript API are likely sources of this).

In order to limit the changes you need to make to your test suite, the Adapter class provides some lower-level translation methods:

  • capybara_find_by_locator(locator): returns a Capybara element corresponding to the given Selenium-RC locator. You can use the Capybara API to do further querying/testing on the returned element.
  • capybara_has_no_locator?(locator): allows you to bypass Capybara's wait when you are trying to test that something isn't present. Maps from a Selenium-RC locator to the appropriate Capybara has_no_* method (has_no_css, has_no_xpath, etc.).
  • capybara_has_locator?(locator): The positive version of the previous method. Similarly maps to the appropriate Capybara has_* method.

Development

Project infrastructure

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cdd/capybara-rc.

License

The gem is available as open source under the terms of the MIT License.