Here is a roundup of recent changes in and around
Capybara. Where they apply to the
Capybara source, they are not included in any release yet, so make sure you are
using the edge version from GitHub (and be prepared for things to break here
- The Celerity and Culerity drivers have been extracted into the capybara-celerity and capybara-culerity gems (5c4f28, by Gabriel Sobrinho). They will be officially supported until (at least) Capybara 1.0, but Jonas recommends using Akephalos as your HtmlUnit driver.
- For RSpec, Capybara now supports
:type => :requestexample groups, as suggested by the rspec-rails gem (558e7b, by yours truly). See the README, section “Using Capybara with RSpec”.
- There is now an (optional) acceptance test DSL for RSpec (f4897f, by Jonas Nicklas and Nicklas Ramhöj). See the README (section “Using Capybara with RSpec”) or Jeff Kreeftmeijer’s blog post.
- The Selenium driver now waits for Ajax requests (021b87, by Maurizio Giambalvo, Jonas, and Nicklas). Search the README for
:resynchronizefor more info.
- Capybara now prefers visible over hidden elements (408423, by Jonas and Nicklas, configurable with
- The RSpec matchers, which are responsible for giving you nice error messages (and allow you to write
- John Firebaugh wrote a capybara-firebug gem to run Capybara with Firebug enabled.
Miscellaneous tips and tricks from around the web:
- Hugo Baraúna of Plataforma suggests that you improve your tests by using Capybara’s custom selectors.
- Carlos Antônio of Plataforma demonstrates how to configure the User-Agent header with Capybara and Selenium.
- Sara Trice shows how to test CKEditor in your pages.
- Jason Neylon has some example code for selecting from a dropdown when you don’t care about its contents.
- Hiroshi Saito suggests a hack to use transactional fixtures with the Akephalos driver.
- Jari Bakken shows how to take screenshots with the Selenium driver.
- Leonid Shevtsov started a discussion on preloading the browser in Spork for Selenium, but we were not able to iron out all the kinks to make it usable. It would be most awesome to get this working, so if anyone has an idea, please post it!
Anything else? Leave a comment!
P.S. Thanks to Elabs for continuing to put company resources into Capybara! Did you know you can hire them to do agile web development for you? (Full disclosure: I’m not affiliated.)