Posted over 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

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

and to features/support/capybara.rb:

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

makandra has been working exclusively with Ruby on Rails since 2007. Our laser focus on a single technology has made us a leader in this space.

Owner of this card:

Avatar
Thomas Klemm
Last edit:
4 months ago
by Daniel Straßner
Attachments:
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