Method: Capybara::Session#reset!

Defined in:
lib/capybara/session.rb

#reset!Object Also known as: cleanup!, reset_session!

Reset the session (i.e. remove cookies and navigate to blank page).

This method does not:

  • accept modal dialogs if they are present (Selenium driver now does, others may not)
  • clear browser cache/HTML 5 local storage/IndexedDB/Web SQL database/etc.
  • modify state of the driver/underlying browser in any other way

as doing so will result in performance downsides and it's not needed to do everything from the list above for most apps.

If you want to do anything from the list above on a general basis you can:

  • write RSpec/Cucumber/etc. after hook
  • monkeypatch this method
  • use Ruby's prepend method


130
131
132
133
134
135
136
137
138
139
# File 'lib/capybara/session.rb', line 130

def reset!
  if @touched
    driver.reset!
    @touched = false
    switch_to_frame(:top) rescue nil # rubocop:disable Style/RescueModifier
    @scopes = [nil]
  end
  @server&.wait_for_pending_requests
  raise_server_error!
end