diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index 9ce09bd..9b165af 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -345,6 +345,32 @@ JS; $element->click(); } + /** + * Click on the element with the provided xpath query + * + * @When /^I click on the element with css selector "([^"]*)"$/ + */ + public function iClickOnTheElementWithCSSSelector($cssSelector) { + $session = $this->getSession(); + $element = $session->getPage()->find( + 'xpath', + $session->getSelectorsHandler()->selectorToXpath('css', $cssSelector) // just changed xpath to css + ); + if (null === $element) { + throw new \InvalidArgumentException(sprintf('Could not evaluate CSS Selector: "%s"', $cssSelector)); + } + + $element->click(); + } + + /** + * @Given /^I click on the element with css selector "([^"]*)", confirming the dialog$/ + */ + public function iClickOnTheElementWithCSSSelectorConfirmingTheDialog($cssSelector) { + $this->iClickOnTheElementWithCSSSelector($cssSelector); + $this->iConfirmTheDialog(); + } + /** * @Given /^I type "([^"]*)" into the dialog$/ */