mirror of
https://github.com/silverstripe/silverstripe-behat-extension
synced 2024-10-22 17:05:32 +02:00
Add double click action
This commit is contained in:
parent
6009c5bdbd
commit
b2ff3e73ad
@ -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$/
|
||||||
|
|
||||||
|
@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user