You are here

protected function AjaxTest::assertWaitPageContains in Drupal 8

Same name and namespace in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/Ajax/AjaxTest.php \Drupal\FunctionalJavascriptTests\Ajax\AjaxTest::assertWaitPageContains()

Asserts that page contains an expected value after waiting.

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 196

Class

AjaxTest
Tests AJAX responses.

Namespace

Drupal\FunctionalJavascriptTests\Ajax

Code

protected function assertWaitPageContains($expected) {
  $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}");
}