Skip to content

Instantly share code, notes, and snippets.

@bfodeke
Created May 23, 2019 15:25
Show Gist options
  • Save bfodeke/99a4fc6c104e67d69faabaefe817474c to your computer and use it in GitHub Desktop.
Save bfodeke/99a4fc6c104e67d69faabaefe817474c to your computer and use it in GitHub Desktop.
Behat: Custom step to test clicking on an element with a class
/**
* Clicks on a css element.
*
* @Given I click the :arg1 element
*/
public function iClickTheElement($selector) {
$page = $this->getSession()->getPage();
$element = $page->find('css', $selector);
if (empty($element)) {
throw new Exception("No html element found for the selector ('$selector')");
}
$element->click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment