1. 程式人生 > >Selenium with Ruby on Rails 3

Selenium with Ruby on Rails 3

Dear Google,

Let it be known that the selenium-on-rails project has not been updated for Rails 3, but you can use the fabulous Capybara to drive Selenium 2 from your Rails test suite.

Capybara is working great for me (Rails 3 and Ruby 1.9) with minimal configuration, and it will even integrate nicely with RSpec or Cucumber! As a bonus, you can selectively switch Selenium off for those tests that don’t require JavaScript support, and they will run directly against the Rack request stack using the same

DSL (complete with XPath support, cookies, form submission, etc.), which is much much faster, and makes agile development a bliss.

So please, next time someone googles selenium rails, let them know that Capybara is there to help, willya?

Thanks, Jo

P.S. If you want to run against any web server on the internet, without any special support for a local Rack/Rails stack, you could also use the official gem directly. (Though to be fair, Capybara supports running against remote servers too, if you need it.)

P.P.S. John Firebaugh provides some more detail on the confusing state of the Selenium Ruby libraries.