You are here

public function FeatureContext::iClickTheRegionElementWithTheCSS in Open Social 8.4

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  2. 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  3. 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  4. 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  5. 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  6. 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  7. 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  8. 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  9. 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()
  10. 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::iClickTheRegionElementWithTheCSS()

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

File

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

Class

FeatureContext
Defines application features from the specific context.

Namespace

Drupal\social\Behat

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