Method: Capybara::Node::Finders#find_link

Defined in:

Find a link on the page. The link can be found by its id or text.

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.


  • locator (String)

    id, test_id attribute, title, text, or alt of enclosed img element

Options Hash (**options):

  • wait (false, true, Numeric)

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

  • href (String, Regexp, nil)

    Value to match against the links href, if nil finds link placeholders (<a> elements with no href attribute), if false ignores the href

  • id (String, Regexp)

    Match links with the id provided

  • title (String)

    Match links with the title provided

  • alt (String)

    Match links with a contained img element whose alt matches

  • download (String, Boolean)

    Match links with the download provided

  • target (String)

    Match links with the target provided

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

    Match links that match the class(es) provided


# File 'lib/capybara/node/finders.rb', line 157

def find_link(locator = nil, **options, &optional_filter_block)
  find(:link, locator, **options, &optional_filter_block)