Ensure that the window is maximised prior to running each step

This commit is contained in:
Damian Mooyman 2014-08-11 14:35:24 +12:00
parent 78cfd94240
commit 01b129de35
1 changed files with 24 additions and 7 deletions

View File

@ -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
*