You are here

private function JSWebAssert::waitForHelper in Drupal 9

Wraps waits in a function to catch curl exceptions to continue waiting.

Parameters

int $timeout: Timeout in milliseconds.

callable $callback: Callback, which result is both used as waiting condition and returned.

Return value

mixed The result of $callback.

4 calls to JSWebAssert::waitForHelper()
JSWebAssert::waitForElement in core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
Waits for the specified selector and returns it when available.
JSWebAssert::waitForElementRemoved in core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
Looks for the specified selector and returns TRUE when it is unavailable.
JSWebAssert::waitForElementVisible in core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
Waits for the specified selector and returns it when available and visible.
JSWebAssert::waitForText in core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
Waits for the specified text and returns its element when available.

File

core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php, line 152

Class

JSWebAssert
Defines a class with methods for asserting presence of elements during tests.

Namespace

Drupal\FunctionalJavascriptTests

Code

private function waitForHelper(int $timeout, callable $callback) {
  WebDriverCurlService::disableRetry();
  $wrapper = function (Element $element) use ($callback) {
    try {
      return call_user_func($callback, $element);
    } catch (CurlExec $e) {
      return NULL;
    }
  };
  $result = $this->session
    ->getPage()
    ->waitFor($timeout / 1000, $wrapper);
  WebDriverCurlService::enableRetry();
  return $result;
}