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-04 06:46:00 +08:00
parent dd8595035f
commit 535e970ad3
No known key found for this signature in database
GPG Key ID: 6D1E3157C8CFBF14

View File

@ -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;
}
}
}