Method: Capybara::Node::Finders#first

Defined in:
lib/capybara/node/finders.rb

#first([kind], locator, options) ⇒ Capybara::Node::Element

Find the first element on the page matching the given selector and options. By default #first will wait up to default_max_wait_time seconds for matching elements to appear and then raise an error if no matching element is found, or nil if the provided count options allow for empty results.

Parameters:

  • kind (Symbol)

    The type of selector

  • locator (String)

    The selector

  • options (Hash)

    Additional options; see #all

Returns:

Raises:



293
294
295
296
# File 'lib/capybara/node/finders.rb', line 293

def first(*args, **options, &optional_filter_block)
  options = { minimum: 1 }.merge(options) unless options_include_minimum?(options)
  all(*args, **options, &optional_filter_block).first
end