Method: Capybara::Session#save_screenshot

Defined in:
lib/capybara/session.rb

#save_screenshot(path = nil, **options) ⇒ String

Save a screenshot of page.

If invoked without arguments it will save file to save_path and file will be given randomly generated filename. If invoked with a relative path the path will be relative to save_path.

Parameters:

  • path (String) (defaults to: nil)

    the path to where it should be saved

  • options (Hash)

    a customizable set of options

Returns:

  • (String)

    the path to which the file was saved



746
747
748
# File 'lib/capybara/session.rb', line 746

def save_screenshot(path = nil, **options)
  prepare_path(path, 'png').tap { |p_path| driver.save_screenshot(p_path, **options) }
end