Method: Capybara::Session#save_page

Defined in:
lib/capybara/session.rb

#save_page(path = nil) ⇒ String

Save a snapshot of the page. If asset_host is set it will inject base tag pointing to asset_host.

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

Returns:

  • (String)

    the path to which the file was saved


703
704
705
706
707
# File 'lib/capybara/session.rb', line 703

def save_page(path = nil)
  prepare_path(path, 'html').tap do |p_path|
    File.write(p_path, Capybara::Helpers.inject_asset_host(body, host: config.asset_host), mode: 'wb')
  end
end