From 98f56e6f4b4d54a9658f12f40fe9ee01a2fc5ea0 Mon Sep 17 00:00:00 2001 From: "Eloy Lafuente (stronk7)" <stronk7@moodle.org> Date: Thu, 9 Apr 2020 14:02:40 +0200 Subject: [PATCH] MDL-67317 behat: Ensure that on every scenario we have a session. Before Mink 1.8.0, any call to getSession() used to auto-start the session if it was not avaliable there. That always has been an unsupported detail. With https://github.com/minkphp/Mink/pull/705 new sessions aren't auto-created anymore. And we were relying on that. So this is, simply about to explicitly create the new session in our before_scenario stuff, to guarantee that it's always there. --- lib/tests/behat/behat_hooks.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 0695b14b55e..c7b53df6b46 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -307,6 +307,9 @@ class behat_hooks extends behat_base { $driverexceptionmsg = 'Selenium server is not running, you need to start it to run tests that involve Javascript. ' . $moreinfo; try { $session = $this->getSession(); + if (!$session->isStarted()) { + $session->start(); + } } catch (CurlExec $e) { // Exception thrown by WebDriver, so only @javascript tests will be caugth; in // behat_util::check_server_status() we already checked that the server is running.