Skip to content

Instantly share code, notes, and snippets.

@acouch
Created Mar 26, 2014
Embed
What would you like to do?
Click on a leaflet map icon in behat using a custom assumption
// Leaflet icons don't haave ids (at least the ones I'm using). Here we can click them by the z-index which is
// the only unique id.
/**
* Click on map icon as identified by its z-index.
*
* @Given /^I click map icon number "([^"]*)"$/
*/
public function iClickMapIcon($num) {
$session = $this->getSession();
$element = $session->getPage()->find(
'xpath',
$session->getSelectorsHandler()->selectorToXpath('xpath', '//img[contains(@style,"z-index: ' . $num . '")]')
);
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Cannot find map icon: "%s"', $num));
}
$element->click();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment