Skip to content

Commit

Permalink
Try to use any module which inherits from WebDriver if WebDriver isn'…
Browse files Browse the repository at this point in the history
…t found (#61)
  • Loading branch information
mklepaczewski authored Jan 27, 2021
1 parent 5ff7ad8 commit be79cdb
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions module/VisualCeption.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,37 @@ public function _failed(TestInterface $test, $fail)
*/
public function _before(TestInterface $test)
{
if (!$this->hasModule($this->config['module'])) {
$browserModule = $this->getBrowserModule();

if ($browserModule === null) {
throw new \Codeception\Exception\ConfigurationException("VisualCeption uses the WebDriver. Please ensure that this module is activated.");
}
if (!class_exists('Imagick')) {
throw new \Codeception\Exception\ConfigurationException("VisualCeption requires ImageMagick PHP Extension but it was not installed");
}

$this->webDriverModule = $this->getModule($this->config['module']);
$this->webDriverModule = $browserModule;
$this->webDriver = $this->webDriverModule->webDriver;

$this->test = $test;
}

protected function getBrowserModule() {
if ($this->hasModule($this->config['module'])) {
return $this->getModule($this->config['module']);
}

foreach($this->getModules() as $module) {
if($module === $this) {
continue;
}
if($module instanceof WebDriver) {
return $module;
}
}

return null;
}

/**
* Get value of the private property $referenceImageDir
Expand Down

0 comments on commit be79cdb

Please sign in to comment.