Method: Capybara::Node::Finders#sibling

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

#sibling(*args, **options, &optional_filter_block) ⇒ Capybara::Node::Element

Find an Element based on the given arguments that is also a sibling of the element called on. #sibling will raise an error if the element is not found.

#sibling takes the same options as #find.

element.sibling('#foo').find('.bar')
element.sibling(:xpath, './/div[contains(., "bar")]')
element.sibling('ul', text: 'Quox').click_link('Delete')

If the driver is capable of executing JavaScript, this method will wait for a set amount of time and continuously retry finding the element until either the element is found or the time expires. The length of time this method will wait is controlled through default_max_wait_time.

Parameters:

  • options (Hash)

    a customizable set of options

  • kind (Symbol)

    Optional selector type (:css, :xpath, :field, etc.). Defaults to default_selector.

  • locator (String)

    The locator for the specified selector

  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • wait (false, true, Numeric)

    Maximum time to wait for matching element to appear. Defaults to default_max_wait_time.

Returns:

Raises:



104
105
106
107
# File 'lib/capybara/node/finders.rb', line 104

def sibling(*args, **options, &optional_filter_block)
  options[:session_options] = session_options
  synced_resolve Capybara::Queries::SiblingQuery.new(*args, **options, &optional_filter_block)
end