Capybara-screenshot Show archive.org snapshot 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.
If your project uses
Spreewald
Show archive.org snapshot
, you can use its Then show me the page
step instead.
Including assets in HTML screenshots for prettier presentation
Note
Capybara takes two kinds of screenshots: a regular image and a copy of the HTML. Capybara does not save any assets referenced from that HTML. With the following config the HTML screenshot will reference assets in the same location where your development server usually provides them.
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'
You might want to replace localhost
with a fitting unique localhost loopback domain.