Created
October 13, 2011 05:31
-
-
Save nordringrayhide/1283471 to your computer and use it in GitHub Desktop.
Capybara screenshot
This file contains hidden or 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
| module Capybara | |
| module Screenshot | |
| module World | |
| def screen_shot_and_save_page | |
| require 'capybara/util/save_and_open_page' | |
| path = "/#{Time.now.strftime('%Y-%m-%d-%H-%M-%S')}" | |
| puts "After body from within Gem: #{page.body}" | |
| Capybara.save_page body, "#{path}.html" | |
| if page.driver.respond_to?(:render) | |
| page.driver.render Rails.root.join "#{Capybara.save_and_open_page_path}" "#{path}.png" | |
| puts "Saved screen shot, #{Capybara.save_and_open_page_path}/#{path}.png" | |
| end | |
| end | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment