diff --git a/README.md b/README.md index e006b2d..cc94c6c 100644 --- a/README.md +++ b/README.md @@ -591,6 +591,10 @@ It's based on the `vendor/bin/behat -di @cms` output. Given /^I (?:press|follow) the "([^"]*)" (?:button|link), confirming the dialog$/ Given /^I (?:press|follow) the "([^"]*)" (?:button|link), dismissing the dialog$/ + + Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, confirming the dialog$/ + + Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, dismissing the dialog$/ Given /^I confirm the dialog$/ diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 0283810..2e06e90 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -396,6 +396,27 @@ JS; $clickTypeFn = $clickTypeMap[$clickType]; $element->$clickTypeFn(); } + + /** + * Needs to be in single command to avoid "unexpected alert open" errors in Selenium. + * Example: I click "Delete" in the ".actions" element, confirming the dialog + * + * @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, confirming the dialog$/ + */ + public function iClickInTheElementConfirmingTheDialog($clickType, $text, $selector) { + $this->iClickInTheElement($clickType, $text, $selector); + $this->iConfirmTheDialog(); + } + /** + * Needs to be in single command to avoid "unexpected alert open" errors in Selenium. + * Example: I click "Delete" in the ".actions" element, dismissing the dialog + * + * @Given /^I (click|double click) "([^"]*)" in the "([^"]*)" element, dismissing the dialog$/ + */ + public function iClickInTheElementDismissingTheDialog($clickType, $text, $selector) { + $this->iClickInTheElement($clickType, $text, $selector); + $this->iDismissTheDialog(); + } /** * @Given /^I type "([^"]*)" into the dialog$/