diff --git a/tests/behat/src/CmsFormsContext.php b/tests/behat/src/CmsFormsContext.php index 3c471fcbfa1..46ddb5ca7a8 100644 --- a/tests/behat/src/CmsFormsContext.php +++ b/tests/behat/src/CmsFormsContext.php @@ -12,6 +12,7 @@ use SilverStripe\BehatExtension\Utility\StepHelper; use Symfony\Component\DomCrawler\Crawler; use Behat\Mink\Element\NodeElement; +use Facebook\WebDriver\WebDriverExpectedCondition; use SilverStripe\SiteConfig\SiteConfig; /** @@ -445,6 +446,23 @@ public function stepIClickTheGridFieldButtonForRow($buttonLabel, $gridFieldName, $button->click(); } + /** + * @When /^I click the "([^"]*)" button in the "([^"]*)" gridfield for the "([^"]*)" row, confirming the dialog$/ + * @param string $buttonLabel + * @param string $gridFieldName + * @param string $rowName + */ + public function stepIClickTheGridFieldButtonForRowConfirmingDialog($buttonLabel, $gridFieldName, $rowName) + { + $this->stepIClickTheGridFieldButtonForRow($buttonLabel, $gridFieldName, $rowName); + $session = $this->getSession()->getDriver()->getWebDriver(); + $session->wait()->until( + WebDriverExpectedCondition::alertIsPresent(), + "Alert is expected" + ); + $session->switchTo()->alert()->accept(); + } + /** * Finds a button in the gridfield row *