public function JSWebAssert::assertNotVisibleInViewport in Drupal 8
Same name and namespace in other branches
- 9 core/tests/Drupal/FunctionalJavascriptTests/JSWebAssert.php \Drupal\FunctionalJavascriptTests\JSWebAssert::assertNotVisibleInViewport()
Test that a node, or its specific corner, is not visible in the viewport.
Note: the node should exist in the page, otherwise this assertion fails.
Parameters
string $selector_type: The element selector type (CSS, XPath).
string|array $selector: The element selector. Note: the first found element is used.
bool|string $corner: (Optional) Corner to test: topLeft, topRight, bottomRight, bottomLeft. Or FALSE to check the complete element (default).
string $message: (optional) A message for the exception.
Throws
\Behat\Mink\Exception\ElementHtmlException When the element doesn't exist.
\Behat\Mink\Exception\ElementNotFoundException When the element is not visible in the viewport.
See also
\Drupal\FunctionalJavascriptTests\JSWebAssert::assertVisibleInViewport()
File
- core/
tests/ Drupal/ FunctionalJavascriptTests/ JSWebAssert.php, line 288
Class
- JSWebAssert
- Defines a class with methods for asserting presence of elements during tests.
Namespace
Drupal\FunctionalJavascriptTestsCode
public function assertNotVisibleInViewport($selector_type, $selector, $corner = FALSE, $message = 'Element is visible in the viewport.') {
$node = $this->session
->getPage()
->find($selector_type, $selector);
if ($node === NULL) {
if (is_array($selector)) {
$selector = implode(' ', $selector);
}
throw new ElementNotFoundException($this->session
->getDriver(), 'element', $selector_type, $selector);
}
$result = $this
->checkNodeVisibilityInViewport($node, $corner);
if ($result) {
throw new ElementHtmlException($message, $this->session
->getDriver(), $node);
}
}