You are here

protected function WebDriverTestBase::assertJsCondition in Drupal 8

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

Waits for the given time or until the given JS condition becomes TRUE.

Parameters

string $condition: JS condition to wait until it becomes TRUE.

int $timeout: (Optional) Timeout in milliseconds, defaults to 10000.

string $message: (optional) A message to display with the assertion. If left blank, a default message will be displayed.

Throws

\PHPUnit\Framework\AssertionFailedError

See also

\Behat\Mink\Driver\DriverInterface::evaluateScript()

25 calls to WebDriverTestBase::assertJsCondition()
BigPipeRegressionTest::testCommentForm_2698811 in core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
Ensure comment form works with history and big_pipe modules.
BigPipeRegressionTest::testMultipleClosingBodies_2678662 in core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
Ensure BigPipe works despite inline JS containing the string "</body>".
BigPipeRegressionTest::testPlaceholderInParagraph_2802923 in core/modules/big_pipe/tests/src/FunctionalJavascript/BigPipeRegressionTest.php
Ensure default BigPipe placeholder HTML cannot split paragraphs.
BookJavascriptTest::testBookOrdering in core/modules/book/tests/src/FunctionalJavascript/BookJavascriptTest.php
Tests re-ordering of books.
BrowserWithJavascriptTest::testAssertJsCondition in core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php

... See full list

File

core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php, line 183

Class

WebDriverTestBase
Runs a browser test using a driver that supports Javascript.

Namespace

Drupal\FunctionalJavascriptTests

Code

protected function assertJsCondition($condition, $timeout = 10000, $message = '') {
  $message = $message ?: "Javascript condition met:\n" . $condition;
  $result = $this
    ->getSession()
    ->getDriver()
    ->wait($timeout, $condition);
  $this
    ->assertTrue($result, $message);
}