function JSWebAssert::waitForText
Same name in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::waitForText()
- 10 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::waitForText()
- 11.x core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::waitForText()
Waits for the specified text and returns its element when available.
Parameters
string $text: The text to wait for.
int $timeout: (Optional) Timeout in milliseconds, defaults to 10000.
Return value
\Behat\Mink\Element\NodeElement|null The page element node if found and visible, NULL if not.
File
-
core/
tests/ Drupal/ FunctionalJavascriptTests/ JSWebAssert.php, line 141
Class
- JSWebAssert
- Defines a class with methods for asserting presence of elements during tests.
Namespace
Drupal\FunctionalJavascriptTestsCode
public function waitForText($text, $timeout = 10000) {
$page = $this->session
->getPage();
return $page->waitFor($timeout / 1000, function () use ($page, $text) {
$actual = preg_replace('/\\s+/u', ' ', $page->getText());
$regex = '/' . preg_quote($text, '/') . '/ui';
return (bool) preg_match($regex, $actual);
});
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.