Skip to content

Instantly share code, notes, and snippets.

@kovalevsky
Created August 7, 2016 20:44
Show Gist options
  • Save kovalevsky/2d055726fa617c9c33f2a7c339dfce70 to your computer and use it in GitHub Desktop.
Save kovalevsky/2d055726fa617c9c33f2a7c339dfce70 to your computer and use it in GitHub Desktop.
Make a screenshots and page dumps
config.after(:each, js: true) do |example|
begin
result_filebase = Rails.root.join('tmp', 'screenshots', "#{DateTime.now.to_i}_#{example.description.gsub(%r{[\x00\/\\:\*\?\"<>\|\s]}, '_')}")
Capybara.page.save_page("#{result_filebase}.html")
Capybara.page.save_screenshot("#{result_filebase}.png", full: true)
rescue
puts 'Capybara driver doesn\'t support screenshot feature'
end if example.exception
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment