function AjaxTest::assertWaitPageContains

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertWaitPageContains()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertWaitPageContains()
  3. 10 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 251

Class

AjaxTest
Tests AJAX responses.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

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}");
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.