Merge pull request #98 from scott1702/add-double-click

Add double click action
This commit is contained in:
Ingo Schommer 2015-10-22 16:29:08 +13:00
commit 95c2e069f4
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 press the "([^"]*)" button$/
Given /^I click "([^"]*)" in the "([^"]*)" element$/ Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element$/
Given /^I type "([^"]*)" into the dialog$/ 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(); $page = $this->getSession()->getPage();
$parentElement = $page->find('css', $selector); $parentElement = $page->find('css', $selector);
assertNotNull($parentElement, sprintf('"%s" element not found', $selector)); assertNotNull($parentElement, sprintf('"%s" element not found', $selector));
$element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text)); $element = $parentElement->find('xpath', sprintf('//*[count(*)=0 and contains(.,"%s")]', $text));
assertNotNull($element, sprintf('"%s" not found', $text)); assertNotNull($element, sprintf('"%s" not found', $text));
$clickTypeFn = $clickTypeMap[$clickType];
$element->click(); $element->$clickTypeFn();
} }
/** /**