From 29f1dcf540c2402dd6b19b5a843fe572b1dbf668 Mon Sep 17 00:00:00 2001 From: Marco Petersen Date: Mon, 20 Mar 2017 09:51:02 +0100 Subject: [PATCH] Allow for custom Selenium capabilities in config file --- src/Extensions/Selenium.php | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Extensions/Selenium.php b/src/Extensions/Selenium.php index 5fd668d..8a5d81b 100644 --- a/src/Extensions/Selenium.php +++ b/src/Extensions/Selenium.php @@ -456,9 +456,8 @@ protected function newSession() $host = isset($config['selenium']['host']) ? $config['selenium']['host'] : 'http://localhost:4444/wd/hub'; $this->webDriver = new WebDriver($host); - $capabilities = []; - return $this->session = $this->webDriver->session($this->getBrowserName(), $capabilities); + return $this->session = $this->webDriver->session($this->getBrowserName(), $this->getCapabilities()); } /** @@ -470,10 +469,26 @@ protected function getBrowserName() { $config = $this->getPackageConfig(); - if (isset($config['selenium'])) { + if (isset($config['selenium']) && isset($config['selenium']['browser'])) { return $config['selenium']['browser']; } return 'firefox'; } + + /** + * Retrieve the desired capabilities for Selenium. + * + * @return array + */ + protected function getCapabilities() + { + $config = $this->getPackageConfig(); + + if (isset($config['selenium']) && isset($config['selenium']['capabilities'])) { + return $config['selenium']['capabilities']; + } + + return []; + } }