Skip to content

Commit

Permalink
Added support for MultiSessionInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
yoda committed Feb 3, 2022
1 parent eccff60 commit 3becdbc
Showing 1 changed file with 50 additions and 1 deletion.
51 changes: 50 additions & 1 deletion module/VisualCeption.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
<?php
namespace Codeception\Module;

use Codeception\Lib\Interfaces\MultiSession as MultiSessionInterface;
use Codeception\Module as CodeceptionModule;
use Codeception\Test\Descriptor;
use Facebook\WebDriver\Exception\UnknownServerException;
use RemoteWebDriver;
use Codeception\Module\VisualCeption\Utils;
use Codeception\TestInterface;
Expand All @@ -19,7 +21,7 @@
* @author Sebastian Neubert
* @author Ray Romanov
*/
class VisualCeption extends CodeceptionModule
class VisualCeption extends CodeceptionModule implements MultiSessionInterface
{
protected $config = [
'maximumDeviation' => 0,
Expand Down Expand Up @@ -575,4 +577,51 @@ protected function _initVisualReport()
}
$this->debug( "VisualCeptionReporter: templateFile = " . $this->templateFile );
}

/**
* Get a new loaded module
*/
public function _initializeSession()
{
$browserModule = $this->getBrowserModule();

$this->webDriverModule = $browserModule;
$this->webDriver = $this->webDriverModule->webDriver;
}

/**
* Loads current RemoteWebDriver instance as a session
*
* @param $session
*/
public function _loadSession($session)
{
$this->webDriver = $session;
}

/**
* Returns current WebDriver session for saving
*
* @return RemoteWebDriver
*/
public function _backupSession()
{
return $this->webDriver;
}

public function _closeSession($session = null)
{
if (!$session and $this->webDriver) {
$session = $this->webDriver;
}
if (!$session) {
return;
}
try {
$session->quit();
unset($webDriver);
} catch (UnknownServerException $e) {
// Session already closed so nothing to do
}
}
}

0 comments on commit 3becdbc

Please sign in to comment.