Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. WebAssert.php

function WebAssert::elementExists

Checks that specific element exists on the current page.

Parameters

string $selectorType element selector type (css, xpath):

string|array $selector element selector:

ElementInterface|null $container document to check against:

Return value

NodeElement

Throws

ElementNotFoundException

6 calls to WebAssert::elementExists()
WebAssert::elementAttributeExists in vendor/behat/mink/src/WebAssert.php
Checks that an attribute exists in an element.
WebAssert::elementAttributeNotExists in vendor/behat/mink/src/WebAssert.php
Checks that an attribute does not exist in an element.
WebAssert::elementContains in vendor/behat/mink/src/WebAssert.php
Checks that specific element contains HTML.
WebAssert::elementNotContains in vendor/behat/mink/src/WebAssert.php
Checks that specific element does not contains HTML.
WebAssert::elementTextContains in vendor/behat/mink/src/WebAssert.php
Checks that specific element contains text.

... See full list

File

vendor/behat/mink/src/WebAssert.php, line 455

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function elementExists(string $selectorType, $selector, ?ElementInterface $container = null) {
    $container = $container ?: $this->session
        ->getPage();
    $node = $container->find($selectorType, $selector);
    if (null === $node) {
        if (is_array($selector)) {
            $selector = implode(' ', $selector);
        }
        throw new ElementNotFoundException($this->session
            ->getDriver(), 'element', $selectorType, $selector);
    }
    return $node;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal