From 1d526bf3e1de14482842f27b36edb5f92b5812e2 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Wed, 22 Nov 2023 17:03:28 +1300 Subject: [PATCH] MNT Add new behat function to allow deleting gridfield rows --- tests/behat/src/CmsFormsContext.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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 *