From 38609c0762e5460702424dc782b7397535911132 Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Tue, 1 Apr 2014 11:04:42 +1300 Subject: [PATCH] Add Behat behaviours to click links and submit forms in preview. --- .../Framework/Test/Behaviour/CmsUiContext.php | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php index c7418590a..7f49a6c57 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php @@ -352,6 +352,42 @@ class CmsUiContext extends BehatContext { $driver->switchToWindow($origWindowName); } + /** + * When I follow "my link" in preview + * + * @When /^(?:|I )follow "(?P(?:[^"]|\\")*)" 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