function WebAssert::elementTextEquals
Same name in other branches
- 9 core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::elementTextEquals()
- 11.x core/tests/Drupal/Tests/WebAssert.php \Drupal\Tests\WebAssert::elementTextEquals()
Asserts a specific element's text equals an expected text.
Parameters
string $selectorType: Element selector type (css, xpath).
string|array $selector: Element selector.
string $text: Expected text.
File
-
core/
tests/ Drupal/ Tests/ WebAssert.php, line 807
Class
- WebAssert
- Defines a class with methods for asserting presence of elements during tests.
Namespace
Drupal\TestsCode
public function elementTextEquals(string $selectorType, $selector, string $text) : void {
$selector_string = is_array($selector) ? '[' . implode(', ', $selector) . ']' : $selector;
$message = "Failed asserting that the text of the element identified by '{$selector_string}' equals '{$text}'.";
$constraint = new IsEqual($text);
Assert::assertThat($this->elementExists($selectorType, $selector)
->getText(), $constraint, $message);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.