Method: Splinter::Capybara::Actions#take_screenshot!
- Defined in:
- lib/splinter/capybara/actions.rb
#take_screenshot!(name = "#{Time.now.strftime('%Y%m%d%H%M%S%L')}") ⇒ Object
Take a screenshot of the current page
name - The name of the screenshot. Uses the current time by default.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/splinter/capybara/actions.rb', line 11 def take_screenshot!(name = "#{Time.now.strftime('%Y%m%d%H%M%S%L')}") unless example.[:js] warn "Screenshots can only be captured when an example is tagged with :js => true" return end if path = Splinter.screenshot_directory args = [File.join(path, "#{name}.png"), Splinter.].compact page.driver.render(*args) puts "Saved screenshot to #{args.first}" else warn "Splinter.screenshot_directory doesn't exist!" end end |