protected function AjaxTest::assertWaitPageContains in Drupal 10
Same name and namespace in other branches
- 8 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertWaitPageContains()
- 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertWaitPageContains()
Asserts that page contains an expected value after waiting.
@internal
Parameters
string $expected: A needle text.
1 call to AjaxTest::assertWaitPageContains()
- AjaxTest::assertInsert in core/
tests/ Drupal/ FunctionalJavascriptTests/ Ajax/ AjaxTest.php - Assert insert.
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ Ajax/ AjaxTest.php, line 200
Class
- AjaxTest
- Tests AJAX responses.
Namespace
Drupal\FunctionalJavascriptTests\AjaxCode
protected function assertWaitPageContains(string $expected) : void {
$page = $this
->getSession()
->getPage();
$this
->assertTrue($page
->waitFor(10, function () use ($page, $expected) {
// Clear content from empty styles and "processed" classes after effect.
$content = str_replace([
' class="processed"',
' processed',
' style=""',
], '', $page
->getContent());
return stripos($content, $expected) !== FALSE;
}), "Page contains expected value: {$expected}");
}