Skip to content

Instantly share code, notes, and snippets.

Created Mar 26, 2014
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(
$session->getSelectorsHandler()->selectorToXpath('xpath', '//img[contains(@style,"z-index: ' . $num . '")]')
if (null === $element) {
throw new \InvalidArgumentException(sprintf('Cannot find map icon: "%s"', $num));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment