diff --git a/src/SilverStripe/BehatExtension/Context/BasicContext.php b/src/SilverStripe/BehatExtension/Context/BasicContext.php index b9071af..716ea7a 100644 --- a/src/SilverStripe/BehatExtension/Context/BasicContext.php +++ b/src/SilverStripe/BehatExtension/Context/BasicContext.php @@ -59,13 +59,15 @@ class BasicContext extends BehatContext $this->context = $parameters; } - /** - * Get Mink session from MinkContext - */ - public function getSession($name = null) - { - return $this->getMainContext()->getSession($name); - } + /** + * Get Mink session from MinkContext + * + * @return \Behat\Mink\Session + */ + public function getSession($name = null) + { + return $this->getMainContext()->getSession($name); + } /** * @AfterStep ~@modal @@ -95,6 +97,21 @@ JS; $this->getSession()->executeScript($javascript); } + /** + * @BeforeStep ~@resizes&&~@modal + * + * Resize the window to maximum size, unless the step will resize itself + */ + public function maximiseWindowBeforeStep(StepEvent $event) { + $driver = $this->getSession()->getDriver(); + if($screenSize = getenv('BEHAT_SCREEN_SIZE')) { + list($screenWidth, $screenHeight) = explode('x', $screenSize); + $driver->resizeWindow((int)$screenWidth, (int)$screenHeight); + } else { + $driver->resizeWindow(1024, 768); + } + } + /** * @AfterStep ~@modal *