You are here

public function JSWebAssert::assertNoElementAfterWait in Drupal 8

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

Asserts that no matching element exists on the page after a wait.

Parameters

string $selector_type: The element selector type (css, xpath).

string|array $selector: The element selector.

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

string $message: (optional) The exception message.

Throws

\Behat\Mink\Exception\ElementHtmlException When an element still exists on the page.

File

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

Class

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

Namespace

Drupal\FunctionalJavascriptTests

Code

public function assertNoElementAfterWait($selector_type, $selector, $timeout = 10000, $message = 'Element exists on the page.') {
  $start = microtime(TRUE);
  $end = $start + $timeout / 1000;
  $page = $this->session
    ->getPage();
  do {
    $node = $page
      ->find($selector_type, $selector);
    if (empty($node)) {
      return;
    }
    usleep(100000);
  } while (microtime(TRUE) < $end);
  throw new ElementHtmlException($message, $this->session
    ->getDriver(), $node);
}