From e631b8c5e139c9c6d5145e93b10420de969f8769 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 28 Jan 2021 15:27:49 +0800 Subject: [PATCH] MDL-66979 behat: Set script timeout with timeout factor --- lib/tests/behat/behat_hooks.php | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 06f78785923..d2f0bea4c75 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -290,13 +290,26 @@ EOF; 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. *