diff --git a/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php b/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
index 16369c0..c511be9 100644
--- a/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
+++ b/core/modules/system/tests/modules/test_page_test/src/Controller/TestPageTestController.php
@@ -2,6 +2,8 @@
 
 namespace Drupal\test_page_test\Controller;
 
+use \Drupal\Core\Url;
+
 /**
  * Controller routines for test_page_test routes.
  */
@@ -11,9 +13,10 @@ class TestPageTestController {
    * Returns a test page and sets the title.
    */
   public function testPage() {
+    $link_text = t('Visually identical test links');
     return [
       '#title' => t('Test page'),
-      '#markup' => t('Test page text.'),
+      '#markup' => t('Test page text.') . "<a href=\"/user/login\">$link_text</a><a href=\"/user/register\">$link_text</a>",
       '#attached' => [
         'drupalSettings' => [
           'test-setting' => 'azAZ09();.,\\\/-_{}',
diff --git a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
index e4979d3..eb5ba4b 100644
--- a/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
+++ b/core/tests/Drupal/FunctionalTests/BrowserTestBaseTest.php
@@ -81,6 +81,21 @@ public function testForm() {
     $this->assertSame('green', $value);
   }
 
+  /**
+   * Tests clickLink() functionality.
+   */
+  public function testClickLink() {
+    $this->drupalGet('test-page');
+    $this->clickLink('Visually identical test links');
+    $this->assertContains('user/login', $this->getSession()->getCurrentUrl());
+    $this->drupalGet('test-page');
+    $this->clickLink('Visually identical test links', 0);
+    $this->assertContains('user/login', $this->getSession()->getCurrentUrl());
+    $this->drupalGet('test-page');
+    $this->clickLink('Visually identical test links', 1);
+    $this->assertContains('user/register', $this->getSession()->getCurrentUrl());
+  }
+
   public function testError() {
     $this->setExpectedException('\Exception', 'User notice: foo');
     $this->drupalGet('test-error');
diff --git a/core/tests/Drupal/Tests/BrowserTestBase.php b/core/tests/Drupal/Tests/BrowserTestBase.php
index ea88906..b4a685e 100644
--- a/core/tests/Drupal/Tests/BrowserTestBase.php
+++ b/core/tests/Drupal/Tests/BrowserTestBase.php
@@ -1615,10 +1615,14 @@ protected function cssSelect($selector) {
    *
    * @param string|\Drupal\Component\Render\MarkupInterface $label
    *   Text between the anchor tags.
+   * @param int $index
+   *   (optional) The index number for cases where multiple links have the same
+   *   text. Defaults to 0.
    */
-  protected function clickLink($label) {
+  protected function clickLink($label, $index = 0) {
     $label = (string) $label;
-    $this->getSession()->getPage()->clickLink($label);
+    $links = $this->getSession()->getPage()->findAll('named', ['link', $label]);
+    $links[$index]->click();
   }
 
   /**
