diff --git a/src/Locator/Locator.php b/src/Locator/Locator.php index 13072ff..0a0260d 100644 --- a/src/Locator/Locator.php +++ b/src/Locator/Locator.php @@ -650,6 +650,7 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m { $start = microtime(true); $timeoutSeconds = $timeoutMs / 1000; + $lastExceptionMessage = ''; while ((microtime(true) - $start) < $timeoutSeconds) { try { @@ -657,12 +658,13 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m return; } } catch (PlaywrightException $e) { + $lastExceptionMessage = $e->getMessage(); } usleep(100000); } - throw new TimeoutException(sprintf('%s (timeout: %dms)', $message, $timeoutMs)); + throw new TimeoutException(sprintf('%s (timeout: %dms): %s', $message, $timeoutMs, $lastExceptionMessage)); } /**