Method: Capybara.configure

Defined in:

.configure {|config| ... } ⇒ Object

Configure Capybara to suit your needs.

Capybara.configure do |config|
  config.run_server = false
  config.app_host   = ''

Configurable options

  • allow_gumbo (Boolean = false) - When nokogumbo is available, whether it will be used to parse HTML strings.
  • always_include_port (Boolean = false) - Whether the Rack server's port should automatically be inserted into every visited URL unless another port is explicitly specified.
  • app_host (String, nil) - The default host to use when giving a relative URL to visit, must be a valid URL e.g.
  • asset_host (String = nil) - Where dynamic assets are hosted - will be prepended to relative asset locations if present.
  • automatic_label_click (Boolean = false) - Whether Element#choose, Element#check, Element#uncheck will attempt to click the associated <label> element if the checkbox/radio button are non-visible.
  • automatic_reload (Boolean = true) - Whether to automatically reload elements as Capybara is waiting.
  • default_max_wait_time (Numeric = 2) - The maximum number of seconds to wait for asynchronous processes to finish.
  • default_normalize_ws (Boolean = false) - Whether text predicates and matchers use normalize whitespace behavior.
  • default_selector (:css, :xpath = :css) - Methods which take a selector use the given type by default. See also Selector.
  • default_set_options (Hash = {}) - The default options passed to Element#set.
  • enable_aria_label (Boolean = false) - Whether fields, links, and buttons will match against aria-label attribute.
  • enable_aria_role (Boolean = false) - Selectors will check for relevant aria role (currently only button).
  • exact (Boolean = false) - Whether locators are matched exactly or with substrings. Only affects selector conditions written using the XPath#is method.
  • exact_text (Boolean = false) - Whether the text matchers and :text filter match exactly or on substrings.
  • ignore_hidden_elements (Boolean = true) - Whether to ignore hidden elements on the page.
  • match (:one, :first, :prefer_exact, :smart = :smart) - The matching strategy to find nodes.
  • predicates_wait (Boolean = true) - Whether Capybara's predicate matchers use waiting behavior by default.
  • raise_server_errors (Boolean = true) - Should errors raised in the server be raised in the tests?
  • reuse_server (Boolean = true) - Whether to reuse the server thread between multiple sessions using the same app object.
  • run_server (Boolean = true) - Whether to start a Rack server for the given Rack app.
  • save_path (String = Dir.pwd) - Where to put pages saved through save_page, save_screenshot, save_and_open_page, or save_and_open_screenshot.
  • server (Symbol = :default (which uses puma)) - The name of the registered server to use when running the app under test.
  • server_port (Integer) - The port Capybara will run the application server on, if not specified a random port will be used.
  • server_errors (Array<Class> = [Exception]) - Error classes that should be raised in the tests if they are raised in the server and raise_server_errors is true.
  • test_id (Symbol, String, nil = nil) - Optional attribute to match locator against with built-in selectors along with id.
  • threadsafe (Boolean = false) - Whether sessions can be configured individually.
  • w3c_click_offset (Boolean = 'false') - Whether click offsets should be from element center (true) or top left (false)

DSL Options

When using capybara/dsl, the following options are also available:

  • default_driver (Symbol = :rack_test) - The name of the driver to use by default.
  • javascript_driver (Symbol = :selenium) - The name of a driver to use for JavaScript enabled tests.


  • (config)

# File 'lib/capybara.rb', line 112

def configure
  yield config