Stefan Wille

Printing the page content in Capybara

December 2, 2010

Capybara is a great integration testing framework that easily replaces Webrat. Plus, it works with Rails 3, which Webrat seems not to do. If you need to print the current page's content, for example to debug your test, you can do so with:

puts page.body

This trick is a bit hard to find in the documentation.

Update: There is also

save_and_open_page

which opens the page content in a browser.