Method: Capybara::Node::Actions#click_link

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

Finds a link by id, test_id attribute, text or title and clicks it. Also looks at image alt text inside the link.

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)

    text, id, test_id attribute, title or nested image's alt attribute

  • options (Hash)

Options Hash (**options):

  • wait (false, true, Numeric)

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

Returns:



41
42
43
# File 'lib/capybara/node/actions.rb', line 41

def click_link(locator = nil, **options)
  find(:link, locator, **options).click
end