Add Behat behaviours to click links and submit forms in preview.

This commit is contained in:
Mateusz Uzdowski 2014-04-01 11:04:42 +13:00
parent 6ae7d43a5d
commit 38609c0762

View File

@ -352,6 +352,42 @@ class CmsUiContext extends BehatContext {
$driver->switchToWindow($origWindowName); $driver->switchToWindow($origWindowName);
} }
/**
* When I follow "my link" in preview
*
* @When /^(?:|I )follow "(?P<link>(?:[^"]|\\")*)" in preview$/
*/
public function clickLinkInPreview($link) {
$driver = $this->getSession()->getDriver();
// TODO Remove once we have native support in Mink and php-webdriver,
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
$origWindowName = $driver->getWebDriverSession()->window_handle();
$driver->switchToIFrame('cms-preview-iframe');
$link = $this->fixStepArgument($link);
$this->getSession()->getPage()->clickLink($link);
$driver->switchToWindow($origWindowName);
}
/**
* When I press "submit" in preview
*
* @When /^(?:|I )press "(?P<button>(?:[^"]|\\")*)" in preview$/
*/
public function pressButtonInPreview($button) {
$driver = $this->getSession()->getDriver();
// TODO Remove once we have native support in Mink and php-webdriver,
// see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI
$origWindowName = $driver->getWebDriverSession()->window_handle();
$driver->switchToIFrame('cms-preview-iframe');
$button = $this->fixStepArgument($button);
$this->getSession()->getPage()->pressButton($button);
$driver->switchToWindow($origWindowName);
}
/** /**
* Workaround for chosen.js dropdowns or tree dropdowns which hide the original dropdown field. * Workaround for chosen.js dropdowns or tree dropdowns which hide the original dropdown field.
* *