Forked from mattheworiordan/capybara_webkit_screenshot_env.rb
Created
April 6, 2012 11:46
-
-
Save oleksiilevzhynskyi/2319114 to your computer and use it in GitHub Desktop.
Cucumber and Capybara-Webkit automatic screenshots on failure
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def screen_shot_and_save_page | |
require 'capybara/util/save_and_open_page' | |
path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}" | |
Capybara.save_page body, "#{path}.html" | |
page.driver.render Rails.root.join "#{Capybara.save_and_open_page_path}" "#{path}.png" | |
end | |
begin | |
After do |scenario| | |
screen_shot_and_save_page if scenario.failed? | |
end | |
rescue Exception => e | |
puts "Snapshots not available for this environment.\n | |
Have you got gem 'capybara-webkit' in your Gemfile and have you enabled the javascript driver?" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment