From 2f5ad614a3720f43d0fd9ab4fe3d38092924aba0 Mon Sep 17 00:00:00 2001 From: Sylvain Gravel Date: Tue, 19 Jan 2016 11:42:21 -0500 Subject: [PATCH 1/2] Allow usage of WPWebDriver w/ Codeception 2 --- src/VisualCeption.php | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/src/VisualCeption.php b/src/VisualCeption.php index a23d070..9a6ff11 100755 --- a/src/VisualCeption.php +++ b/src/VisualCeption.php @@ -24,6 +24,7 @@ class VisualCeption extends \Codeception\Module { private $maximumDeviation = 0; + private $webDriverClass = 'WebDriver'; /** * @var \RemoteWebDriver @@ -35,29 +36,20 @@ class VisualCeption extends \Codeception\Module */ private $storageStrategy; - /** - * Create an object from VisualCeption Class - * - * @param array $config - * @return result - */ - public function __construct($config) - { - $result = parent::__construct($config); - $this->init(); - return $result; - } - /** * Initialize the module and read the config. * * @throws \RuntimeException */ - private function init() + private function _initialize() { if (array_key_exists('maximumDeviation', $this->config)) { $this->maximumDeviation = $this->config["maximumDeviation"]; } + + if (array_key_exists('webdriver', $this->config)) { + $this->webDriverClass = $this->config["webdriver"]; + } $this->storageStrategy = Factory::getStorage($this->config); } @@ -70,10 +62,10 @@ private function init() */ public function _before(\Codeception\TestCase $test) { - if (!$this->hasModule("WebDriver")) { - throw new \Exception("VisualCeption uses the WebDriver. Please be sure that this module is activated."); + if (!$this->hasModule($this->webDriverClass)) { + throw new \Exception("VisualCeption uses the " . $this->webDriverClass . ". Please be sure that this module is activated."); } - $this->webDriver = $this->getModule("WebDriver")->webDriver; + $this->webDriver = $this->getModule($this->webDriverClass)->webDriver; } /** From dc2dbc8e7c6e66a5b837db41663909d0d662af29 Mon Sep 17 00:00:00 2001 From: Sylvain Gravel Date: Tue, 19 Jan 2016 12:54:22 -0500 Subject: [PATCH 2/2] Changed class for Codeception 2.2 Facebook WebDriver --- src/VisualCeption/Html/Manipulation.php | 2 +- src/VisualCeption/Html/Screenshot.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/VisualCeption/Html/Manipulation.php b/src/VisualCeption/Html/Manipulation.php index 5cd733e..f432ae4 100755 --- a/src/VisualCeption/Html/Manipulation.php +++ b/src/VisualCeption/Html/Manipulation.php @@ -6,7 +6,7 @@ class Manipulation { private $webDriver; - public function __construct(\RemoteWebDriver $webDriver) + public function __construct(\Facebook\WebDriver\Remote\RemoteWebDriver $webDriver) { $this->webDriver = $webDriver; $this->injectJQuery(); diff --git a/src/VisualCeption/Html/Screenshot.php b/src/VisualCeption/Html/Screenshot.php index 05df496..d62b3fe 100755 --- a/src/VisualCeption/Html/Screenshot.php +++ b/src/VisualCeption/Html/Screenshot.php @@ -6,7 +6,7 @@ class Screenshot { private $webDriver; - public function __construct(\RemoteWebDriver $webDriver) + public function __construct(\Facebook\WebDriver\Remote\RemoteWebDriver $webDriver) { $this->webDriver = $webDriver; }