Method: Capybara::Node::Finders#find_button

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

#find_button([locator], **options) ⇒ Capybara::Node::Element

Find a button on the page. This can be any <input> element of type submit, reset, image, button or it can be a <button> element. All buttons can be found by their id, name, test_id attribute, value, or title. <button> elements can also be found by their text content, and image <input> elements by their alt attribute.

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:

  • locator (String)

    id, name, test_id attribute, value, title, text content, alt of image

Options Hash (**options):

  • wait (false, true, Numeric)

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

  • disabled (Boolean, Symbol) — default: false

    Match disabled button?

    • true - only finds a disabled button
    • false - only finds an enabled button
    • :all - finds either an enabled or disabled button
  • id (String, Regexp)

    Match buttons with the id provided

  • name (String)

    Match buttons with the name provided

  • title (String)

    Match buttons with the title provided

  • value (String)

    Match buttons with the value provided

  • class (String, Array<String>, Regexp)

    Match buttons that match the class(es) provided

Returns:



184
185
186
# File 'lib/capybara/node/finders.rb', line 184

def find_button(locator = nil, **options, &optional_filter_block)
  find(:button, locator, **options, &optional_filter_block)
end