You are here

protected function WebDriverTestBase::assertJsCondition in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/FunctionalJavascriptTests/WebDriverTestBase.php \Drupal\FunctionalJavascriptTests\WebDriverTestBase::assertJsCondition()
  2. 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()

3 calls to WebDriverTestBase::assertJsCondition()
BrowserWithJavascriptTest::testAssertJsCondition in core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
BrowserWithJavascriptTest::testJavascript in core/tests/Drupal/FunctionalJavascriptTests/BrowserWithJavascriptTest.php
MachineNameTest::testMachineName in core/tests/Drupal/FunctionalJavascriptTests/Core/MachineNameTest.php
Tests that machine name field functions.

File

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

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