Skip to content

Commit

Permalink
Merge branch 'MDL-66979-master-7' of git://github.com/andrewnicols/mo…
Browse files Browse the repository at this point in the history
…odle
  • Loading branch information
stronk7 committed Jan 28, 2021
2 parents 3a8e9d7 + 5d8e4e9 commit 2eebe68
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions config-dist.php
Expand Up @@ -898,7 +898,7 @@
// ),
// 'extensions' => array(
// 'Behat\MinkExtension' => array(
// 'selenium2' => array(
// 'webddriver' => array(
// 'browser' => 'firefox',
// 'capabilities' => array(
// 'platform' => 'OS X 10.6',
Expand All @@ -911,7 +911,7 @@
// 'Mac-Safari' => array(
// 'extensions' => array(
// 'Behat\MinkExtension' => array(
// 'selenium2' => array(
// 'webddriver' => array(
// 'browser' => 'safari',
// 'capabilities' => array(
// 'platform' => 'OS X 10.8',
Expand Down
34 changes: 32 additions & 2 deletions lib/tests/behat/behat_hooks.php
Expand Up @@ -290,13 +290,26 @@ protected function restart_session(): void {
if ($session->isStarted()) {
$session->restart();
} else {
$session->start();
$this->start_session();
}
if ($this->running_javascript() && $this->getSession()->getDriver()->getWebDriverSessionId() === 'session') {
throw new DriverException('Unable to create a valid session');
}
}

/**
* Start the Session, applying any initial configuratino required.
*/
protected function start_session(): void {
$this->getSession()->start();

$this->getSession()->getDriver()->setTimeouts([
// The standard script timeout is 30000 ms.
// Use `get_real_timeout` to multiply this by the behat increased timeout factor.
'script' => self::get_real_timeout(30000),
]);
}

/**
* Restart the session before each non-javascript scenario.
*
Expand Down Expand Up @@ -660,7 +673,24 @@ public function after_step_javascript(AfterStepScope $scope) {
* @AfterScenario
*/
public function reset_webdriver_between_scenarios(AfterScenarioScope $scope) {
$this->getSession()->stop();
try {
$this->getSession()->stop();
} catch (Exception $e) {
$error = <<<EOF
Error while stopping WebDriver: %s (%d) '%s'
Attempting to continue with test run. Stacktrace follows:
%s
EOF;
error_log(sprintf(
$error,
get_class($e),
$e->getCode(),
$e->getMessage(),
format_backtrace($e->getTrace(), true)
));
}
}

/**
Expand Down

0 comments on commit 2eebe68

Please sign in to comment.