From d003707894bea9d1a1fb9a6ab69ead6941abe45d Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Tue, 25 Feb 2014 11:33:12 +1300 Subject: [PATCH] BEHAT_SCREEN_SIZE env var --- README.md | 9 +++++++++ .../BehatExtension/Context/SilverStripeContext.php | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/README.md b/README.md index ee74da4..cd8fd22 100644 --- a/README.md +++ b/README.md @@ -280,6 +280,15 @@ Example: mymodule/tests/behat/features/bootstrap/MyModule/Test/Behaviour/Feature } } +### Screen Size + +In some Selenium drivers like [SauceLabs](http://www.saucelabs.com) you can +define the desired browser window size through a `capabilities` definition. +By default, Selenium doesn't support this though, so we've added a workaround +through an environment variable: + + BEHAT_SCREEN_SIZE=320x600 vendor/bin/behat + ## FAQ ### FeatureContext not found diff --git a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php index 1b4ab03..bcac52e 100644 --- a/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php +++ b/src/SilverStripe/BehatExtension/Context/SilverStripeContext.php @@ -131,6 +131,11 @@ class SilverStripeContext extends MinkContext implements SilverStripeAwareContex } $this->testSessionEnvironment->startTestSession($this->getTestSessionState()); + + if($screenSize = getenv('BEHAT_SCREEN_SIZE')) { + list($screenWidth, $screenHeight) = explode('x', $screenSize); + $this->getSession()->resizeWindow((int)$screenWidth, (int)$screenHeight); + } } /**