You are here

public function RulesBrowserTestBase::clickLinkByHref in Rules 8.3

Clicks a link identified via partial href using xpath.

As the Rules UI pages become more complex, with multiple links and buttons containing the same text, it may get difficult to use clickLink('text', N) where N is the index position on the page, as the index of a given link varies depending on other rules. It is clearer to read and more future-proof to find the link via a known url fragment.

Parameters

string $href: The href, or a unique part of it.

1 call to RulesBrowserTestBase::clickLinkByHref()
ConfigureAndExecuteTest::testTwoRulesSameEvent in tests/src/Functional/ConfigureAndExecuteTest.php
Tests creating and altering two rules reacting on the same event.

File

tests/src/Functional/RulesBrowserTestBase.php, line 42

Class

RulesBrowserTestBase
Has some additional helper methods to make test code more readable.

Namespace

Drupal\Tests\rules\Functional

Code

public function clickLinkByHref($href) {
  $this
    ->getSession()
    ->getPage()
    ->find('xpath', './/a[contains(@href, "' . $href . '")]')
    ->click();
}