Opinionated Programmer - Jo Liss's musings on enlightened software development.

Screenshots with Capybara

Just so I’ll never have to google this again, here is how to save and open a screenshot with Capybara when you are using the :selenium driver:

1
2
page.driver.browser.save_screenshot 'screenshot.png'
Launchy.open 'screenshot.png' # or open manually

Update: In Capybara 2.0.0.beta2, screenshotting has become part of the API and can be done like this:

1
2
page.save_screenshot 'screenshot.png'
Launchy.open 'screenshot.png' # or open manually