Skip to content

Commit

Permalink
Ensure remote web driver is not null before executing
Browse files Browse the repository at this point in the history
  • Loading branch information
tr33m4n committed Apr 14, 2022
1 parent ed8d039 commit a556cc8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/Codeception/Module/Percy.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public function takeAPercySnapshot(
return;
}

// If remote web driver has not been set, return
if (null === $this->webDriver->webDriver) {
return;
}

// Add Percy CLI JS to page
$this->webDriver->executeJS($this->percyCliJs);

Expand All @@ -106,7 +111,7 @@ public function takeAPercySnapshot(
)
))
->withClientInfo(InfoProvider::getClientInfo())
->withEnvironmentInfo(InfoProvider::getEnvironmentInfo($this->webDriver))
->withEnvironmentInfo(InfoProvider::getEnvironmentInfo($this->webDriver->webDriver))
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/Codeception/Module/Percy/InfoProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Codeception\Module\Percy;

use Codeception\Module\WebDriver;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use PackageVersions\Versions;

final class InfoProvider
Expand All @@ -18,16 +18,16 @@ final class InfoProvider
/**
* Get environment info
*
* @param \Codeception\Module\WebDriver $webDriver
* @param \Facebook\WebDriver\Remote\RemoteWebDriver $webDriver
* @return string
*/
public static function getEnvironmentInfo(WebDriver $webDriver): string
public static function getEnvironmentInfo(RemoteWebDriver $webDriver): string
{
if (null !== self::$environmentInfo) {
return self::$environmentInfo;
}

$webDriverCapabilities = $webDriver->webDriver->getCapabilities();
$webDriverCapabilities = $webDriver->getCapabilities();

return self::$environmentInfo = sprintf(
'codeception-php; %s; %s/%s',
Expand Down

0 comments on commit a556cc8

Please sign in to comment.