You are here

protected function UiHelperTrait::clickLink in Drupal 9

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::clickLink()
  2. 10 core/tests/Drupal/Tests/UiHelperTrait.php \Drupal\Tests\UiHelperTrait::clickLink()

Follows a link by complete name.

Will click the first link found with this link text.

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: (optional) The index number for cases where multiple links have the same text. Defaults to 0.

226 calls to UiHelperTrait::clickLink()
AggregatorAdminTest::testSettingsPage in core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php
Tests the settings form to ensure the correct default values are used.
AggregatorTestBase::updateFeedItems in core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php
Updates the feed items.
AjaxBlockTest::testAddAjaxBlock in core/modules/layout_builder/tests/src/FunctionalJavascript/AjaxBlockTest.php
Tests configuring a field block for a user field.
AjaxTest::assertInsert in core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php
Assert insert.
AjaxTest::testAjaxWithAdminRoute in core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php

... See full list

File

core/tests/Drupal/Tests/UiHelperTrait.php, line 500

Class

UiHelperTrait
Provides UI helper methods.

Namespace

Drupal\Tests

Code

protected function clickLink($label, $index = 0) {
  $label = (string) $label;
  $links = $this
    ->getSession()
    ->getPage()
    ->findAll('named', [
    'link',
    $label,
  ]);
  $this
    ->assertArrayHasKey($index, $links, 'The link ' . $label . ' was not found on the page.');
  $links[$index]
    ->click();
}