Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NEW: Adding some Behat steps for css selectors and Dialog confirmation #21

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 26 additions & 0 deletions src/SilverStripe/BehatExtension/Context/BasicContext.php
Expand Up @@ -345,6 +345,32 @@ public function iClickInTheElement($text, $selector)
$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$/
*/
Expand Down