Method: Capybara::Node::Actions#click_button

Defined in:

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

Finds a button on the page and clicks it. 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.


Options Hash (**options):

  • wait (false, true, Numeric)

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


# File 'lib/capybara/node/actions.rb', line 57

def click_button(locator = nil, **options)
  find(:button, locator, options).click