You are here

public function WebAssert::elementsCount in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/behat/mink/src/WebAssert.php \Behat\Mink\WebAssert::elementsCount()

Checks that there is specified number of specific elements on the page.

Parameters

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

string|array $selector element selector:

int $count expected count:

ElementInterface $container document to check against:

Throws

ExpectationException

File

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

Class

WebAssert
Mink web assertions tool.

Namespace

Behat\Mink

Code

public function elementsCount($selectorType, $selector, $count, ElementInterface $container = null) {
  $container = $container ?: $this->session
    ->getPage();
  $nodes = $container
    ->findAll($selectorType, $selector);
  $message = sprintf('%d %s found on the page, but should be %d.', count($nodes), $this
    ->getMatchingElementRepresentation($selectorType, $selector, count($nodes) !== 1), $count);
  $this
    ->assert(intval($count) === count($nodes), $message);
}