Created
March 26, 2014 14:33
-
-
Save acouch/9784746 to your computer and use it in GitHub Desktop.
Click on a leaflet map icon in behat using a custom assumption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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