You are here

public function FeatureContext::iClickTheElementWithTheCSS in Open Social 8

Same name and namespace in other branches
  1. 8.2 tests/behat/features/bootstrap/FeatureContext.php \FeatureContext::iClickTheElementWithTheCSS()

@When I click the xth :position element with the css :css

File

tests/behat/features/bootstrap/FeatureContext.php, line 266

Class

FeatureContext
Defines application features from the specific context.

Code

public function iClickTheElementWithTheCSS($position, $css) {
  $session = $this
    ->getSession();
  $elements = $session
    ->getPage()
    ->findAll('css', $css);
  $count = 0;
  foreach ($elements as $element) {
    if ($count == $position) {

      // Now click the element.
      $element
        ->click();
      return;
    }
    $count++;
  }
  throw new \InvalidArgumentException(sprintf('Element not found with the css: "%s"', $css));
}