Add double click action

This commit is contained in:
scott1702 2015-10-22 16:13:47 +13:00
parent 6009c5bdbd
commit b2ff3e73ad
2 changed files with 9 additions and 7 deletions

View File

@ -584,7 +584,7 @@ It's based on the `vendor/bin/behat -di @cms` output.
Given /^I press the "([^"]*)" button$/
Given /^I click "([^"]*)" in the "([^"]*)" element$/
Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element$/
Given /^I type "([^"]*)" into the dialog$/

View File

@ -381,18 +381,20 @@ JS;
}
/**
* @Given /^I click "([^"]*)" in the "([^"]*)" element$/
* @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element$/
*/
public function iClickInTheElement($text, $selector) {
public function iClickInTheElement($clickType, $text, $selector) {
$clickTypeMap = array(
"double click" => "doubleclick",
"click" => "click"
);
$page = $this->getSession()->getPage();
$parentElement = $page->find('css', $selector);
assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
$element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
assertNotNull($element, sprintf('"%s" not found', $text));
$element->click();
$clickTypeFn = $clickTypeMap[$clickType];
$element->$clickTypeFn();
}
/**