function JSWebAssert::waitForElementVisible

Same name in other branches
  1. 9 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::waitForElementVisible()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::waitForElementVisible()
  3. 11.x core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::waitForElementVisible()

Waits for the specified selector and returns it when available and visible.

Parameters

string $selector: The selector engine name. See ElementInterface::findAll() for the supported selectors.

string|array $locator: The selector locator.

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

Return value

\Behat\Mink\Element\NodeElement|null The page element node if found and visible, NULL if not.

See also

\Behat\Mink\Element\ElementInterface::findAll()

1 call to JSWebAssert::waitForElementVisible()
JSWebAssert::waitOnAutocomplete in core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php
Waits for the jQuery autocomplete delay duration.

File

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

Class

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

Namespace

Drupal\FunctionalJavascriptTests

Code

public function waitForElementVisible($selector, $locator, $timeout = 10000) {
    $page = $this->session
        ->getPage();
    $result = $page->waitFor($timeout / 1000, function () use ($page, $selector, $locator) {
        $element = $page->find($selector, $locator);
        if (!empty($element) && $element->isVisible()) {
            return $element;
        }
        return NULL;
    });
    return $result;
}

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