You are here

public function ElementContext::matchAtLeast in Lightning Core 8.3

Same name and namespace in other branches
  1. 8.5 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::matchAtLeast()
  2. 8 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::matchAtLeast()
  3. 8.2 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::matchAtLeast()
  4. 8.4 tests/contexts/ElementContext.behat.inc \Acquia\LightningExtension\Context\ElementContext::matchAtLeast()

Asserts that a minimum number of elements match a CSS selector.

@Then at least :n element(s) should match :selector

Parameters

string $selector: The selector.

int $n: The number of elements expected to match the selector.

Throws

\Behat\Mink\Exception\ExpectationException If the fewer elements than expected match the selector.

File

tests/contexts/ElementContext.behat.inc, line 436

Class

ElementContext
Contains miscellaneous step definitions for working with HTML elements.

Namespace

Acquia\LightningExtension\Context

Code

public function matchAtLeast($selector, $n) {
  $session = $this
    ->getSession();
  $count = count($session
    ->getPage()
    ->findAll('css', $selector));
  if ($count < $n) {
    throw new ExpectationException("Expected '{$selector}' to match at least {$n} elements, but it matched {$count}.", $session
      ->getDriver());
  }
}