Skip to content

Instantly share code, notes, and snippets.

@suhrawardi
Created September 21, 2010 09:53
Show Gist options
  • Save suhrawardi/589483 to your computer and use it in GitHub Desktop.
Save suhrawardi/589483 to your computer and use it in GitHub Desktop.
# This is an example of how you can set up screenshots for your
# browser testing. Just run cucumber with --format html --out report.html
#
module Screenshots
def embed_screenshot(id)
%x(scrot #{$ROOT_PATH}/images/#{id}.png)
end
end
World(Screenshots)
# Only take screenshot for scenarios or features tagged @screenshot
#
# After(@screenshots) do
# embed_screenshot("screenshot-#{Time.new.to_i}")
# end
#
# Only take screenshot on failures
After do |scenario|
embed_screenshot("screenshot-#{Time.new.to_i}") if scenario.failed?
end
# Other variants:
#
# After do
# $stderr.puts "Attempting to make a screenshot" if $DEBUG
# embed_screenshot("screenshot-#{Time.new.to_i}")
# $stderr.puts "Ok !" if $DEBUG
# end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment