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 f6078ff17..ed897da5b 100644 --- a/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php +++ b/tests/behat/features/bootstrap/SilverStripe/Framework/Test/Behaviour/CmsUiContext.php @@ -245,10 +245,13 @@ class CmsUiContext extends BehatContext public function thePreviewContains($content) { $driver = $this->getSession()->getDriver(); - $driver->switchToIFrame('cms-preview-iframe'); + // 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'); $this->getMainContext()->assertPageContainsText($content); - $driver->switchToWindow(); + $driver->switchToWindow($origWindowName); } /** @@ -257,10 +260,13 @@ class CmsUiContext extends BehatContext public function thePreviewDoesNotContain($content) { $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'); - $this->getMainContext()->assertPageNotContainsText($content); - $driver->switchToWindow(); + $driver->switchToWindow($origWindowName); } /**