MDL-82373 behat: Stop killing the entire Behat run on driver error

If there's a driver error, for example from a step taking too long, then
this kills the entire Behat run and we have to start from scratch.

This change instead throws away the original connection and starts a new
one to try and continue the test.
This commit is contained in:
Andrew Nicols
2024-07-17 13:29:44 +08:00
parent beb6ab9e4e
commit 3d43a712bc
@@ -16,6 +16,7 @@
namespace Moodle\BehatExtension\Driver;
use Behat\Mink\Exception\DriverException;
use OAndreyev\Mink\Driver\WebDriver as UpstreamDriver;
// phpcs:disable moodle.NamingConventions.ValidFunctionName.LowercaseMethod
@@ -79,4 +80,14 @@ class WebDriver extends UpstreamDriver {
public function post_key($key, $xpath) {
throw new \Exception('No longer used - please use keyDown and keyUp');
}
#[\Override]
public function stop(): void {
try {
parent::stop();
} catch (DriverException $e) {
error_log($e->getMessage());
$this->webDriver = null;
}
}
}