Posted about 5 years ago. Visible to the public. Repeats. Linked content.

Taking screenshots in Capybara

Capybara-screenshot can automatically save screenshots and the HTML for failed Capybara tests in Cucumber, RSpec or Minitest.

Requires Capybara-Webkit, Selenium or poltergeist for making screenshots. They're saved into $APPLICATION_ROOT/tmp/capybara

The attached files contain config for cucumber integration and a Then show me a screenshot step.

Including assets for prettier presentation

Make sure to add this to config/environments/test.rb

# Do not generate digests for assets URLs. config.assets.digest = false

and to features/support/capybara.rb:

# Have HTML screenshot render with assets (while `b rails s` is running) Capybara.asset_host = 'http://localhost:3000'

Does your version of Ruby on Rails still receive security updates?
Rails LTS provides security patches for old versions of Ruby on Rails (3.2 and 2.3).

Owner of this card:

Thomas Klemm
Last edit:
about 1 month ago
by Daniel Straßner
capybara_screenshot.rb, screenshot_steps.rb
About this deck:
We are makandra and do test-driven, agile Ruby on Rails software development.
License for source code
Posted by Thomas Klemm to makandra dev
This website uses cookies to improve usability and analyze traffic.
Accept or learn more