From 54edc0ddacd421690b5d3e7a34de5bafa6fcdf58 Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 22 Aug 2013 12:48:11 +0200 Subject: [PATCH] Fix Behat window switching in chrome Workaround only, see https://groups.google.com/forum/#!topic/behat/QNhOuGHKEWI --- .../Framework/Test/Behaviour/CmsUiContext.php | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) 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); } /**