Capybara on the Command Line - Live Browser Testing From IRB

Everyone knows retro fitting tests is not the best way to go, but you can't escape the fact that sometimes it's unavoidable. Writing integration tests after the fact can sometimes be tricky, especially when dealing with complex xpaths or trying to assert against deeply buried elements. So if you're as tired of digging around in web inspector as I am, try this instead:

gem install capybara

And then fire up console:

require 'capybara/dsl'
=> true 
include Capybara::DSL
=> Object 
Capybara.default_driver = :selenium
=> :selenium 
visit "http://google.co.uk"
=> ""

Watch and smile as Firefox opens, and then access anything on it with page

page.fill_in('q', :with => 'capybara')
=> ""
page.click_link "jnicklas/capybara - GitHub"
=> "ok"

And by getting instant feedback in this way, those steps will write themselves.