function WebTestBase::clickLink

Follows a link by complete name.

Will click the first link found with this link text by default, or a later one if an index is given. Match is case sensitive with normalized space. The label is translated label.

If the link is discovered and clicked, the test passes. Fail otherwise.

Parameters

string|\Drupal\Component\Render\MarkupInterface $label: Text between the anchor tags.

int $index: Link position counting from zero.

Return value

string|bool Page contents on success, or FALSE on failure.

4 calls to WebTestBase::clickLink()
AggregatorTestBase::updateFeedItems in core/modules/aggregator/src/Tests/AggregatorTestBase.php
Updates the feed items.
BrowserTest::testGetAbsoluteUrl in core/modules/simpletest/src/Tests/BrowserTest.php
Test \Drupal\simpletest\WebTestBase::getAbsoluteUrl().
UpdatePathTestBase::runUpdates in core/modules/system/src/Tests/Update/UpdatePathTestBase.php
Helper function to run pending database updates.
UpdateTestBase::refreshUpdateStatus in core/modules/update/src/Tests/UpdateTestBase.php
Refreshes the update status based on the desired available update scenario.

File

core/modules/simpletest/src/WebTestBase.php, line 1695

Class

WebTestBase
Test case for typical Drupal tests.

Namespace

Drupal\simpletest

Code

protected function clickLink($label, $index = 0) {
    return $this->clickLinkHelper($label, $index, '//a[normalize-space()=:label]');
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.