You are here

public function ElementContext::matchAtLeast in Lightning Core 8.2

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.3 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

ExpectationException if the number of elements that match the selector is less than expected.

File

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

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());
  }
}