You are here

public function FeatureContext::iClickTheRegionElementWithTheCSS in Open Social 8.2

@When I click the xth :position element with the css :css in the :region( region)

File

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

Class

FeatureContext
Defines application features from the specific context.

Code

public function iClickTheRegionElementWithTheCSS($position, $css, $region) {
  $session = $this
    ->getSession();
  $regionObj = $session
    ->getPage()
    ->find('region', $region);
  $elements = $regionObj
    ->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));
}