Skip to content

Commit

Permalink
Throw error if selenium is not running. (#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
tannguyen04 authored Mar 8, 2024
1 parent 763ec2a commit 2a918d2
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions src/DrevOps/BehatScreenshotExtension/Context/ScreenshotContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,22 @@ public function beforeScenarioInit(BeforeScenarioScope $scope): void
if ($scope->getScenario()->hasTag('javascript')) {
$driver = $this->getSession()->getDriver();
if ($driver instanceof Selenium2Driver) {
// Start driver's session manually if it is not already started.
if (!$driver->isStarted()) {
$driver->start();
try {
// Start driver's session manually if it is not already started.
if (!$driver->isStarted()) {
$driver->start();
}
$this->getSession()->resizeWindow(1440, 900, 'current');
} catch (\Exception $exception) {
throw new \RuntimeException(
sprintf(
'Please make sure that Selenium server is running. %s',
$exception->getMessage(),
),
$exception->getCode(),
$exception,
);
}
$this->getSession()->resizeWindow(1440, 900, 'current');
}
}
}
Expand Down

0 comments on commit 2a918d2

Please sign in to comment.