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.
- 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.
Add this line to your application's Gemfile:
And then execute:
Or install it yourself as:
$ gem install capybara-rc
- 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)
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
In order to limit the changes you need to make to your test suite, the
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.
After checking out the repo, run
bin/setup to install dependencies. Then, run
rake spec to run the tests. You can also run
bin/console for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run
bundle exec rake install. To release a new version, update the version number in
version.rb, and then run
bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the
.gem file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/cdd/capybara-rc.
The gem is available as open source under the terms of the MIT License.