From 3b97a56c6aa41b35ffc67fa10d9396418c47f8f5 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 8 Jul 2020 15:35:11 +0800 Subject: [PATCH] MDL-69232 behat: Add debugging information to Selenium fails --- lib/tests/behat/behat_hooks.php | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index 11f4e71974f..d9ee40a8d8f 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -312,12 +312,23 @@ class behat_hooks extends behat_base { } 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. - throw new behat_stop_exception($driverexceptionmsg); + throw new behat_stop_exception( + $driverexceptionmsg . '. ' . + $e->getMessage() . "\n\n" . + format_backtrace($e->getTrace(), true) + ); } catch (DriverException $e) { - throw new behat_stop_exception($driverexceptionmsg); + throw new behat_stop_exception( + $driverexceptionmsg . '. ' . + $e->getMessage() . "\n\n" . + format_backtrace($e->getTrace(), true) + ); } catch (UnknownError $e) { // Generic 'I have no idea' Selenium error. Custom exception to provide more feedback about possible solutions. - throw new behat_stop_exception($e->getMessage()); + throw new behat_stop_exception( + $e->getMessage() . "\n\n" . + format_backtrace($e->getTrace(), true) + ); } $suitename = $scope->getSuite()->getName();