class Capybara::Session

The {Session} class represents a single user’s interaction with the system. The {Session} can use any of the underlying drivers. A session can be initialized manually like this:

session = Capybara::Session.new(:culerity, MyRackApp)

The application given as the second argument is optional. When running Capybara against an external page, you might want to leave it out:

session = Capybara::Session.new(:culerity)
session.visit('http://www.google.com')

When {Capybara.configure threadsafe} is ‘true` the sessions options will be initially set to the current values of the global options and a configuration block can be passed to the session initializer. For available options see {Capybara::SessionConfig::OPTIONS}:

session = Capybara::Session.new(:driver, MyRackApp) do |config|
  config.app_host = "http://my_host.dev"
end

The {Session} provides a number of methods for controlling the navigation of the page, such as {#visit}, {#current_path}, and so on. It also delegates a number of methods to a {Capybara::Document}, representing the current HTML document. This allows interaction:

session.fill_in('q', with: 'Capybara')
session.click_button('Search')
expect(session).to have_content('Capybara')

When using ‘capybara/dsl`, the {Session} is initialized automatically for you.