function JSWebAssert::assertNoElementAfterWait

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::assertNoElementAfterWait()
  2. 8.9.x core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::assertNoElementAfterWait()
  3. 11.x 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 558

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

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.