function 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|null $container document to check against:
Return value
void
Throws
File
-
vendor/
behat/ mink/ src/ WebAssert.php, line 429
Class
- WebAssert
- Mink web assertions tool.
Namespace
Behat\MinkCode
public function elementsCount(string $selectorType, $selector, int $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);
}