From bacbdf238691b1ececdcbe9d5d604608e975cb35 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Thu, 23 Nov 2017 13:38:00 +0000 Subject: [PATCH 1/2] Detect javascript errors when visiting a new web page --- src/ZombieDriver.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/ZombieDriver.php b/src/ZombieDriver.php index d4ddfa2..42e25b5 100644 --- a/src/ZombieDriver.php +++ b/src/ZombieDriver.php @@ -125,7 +125,10 @@ public function visit($url) } }); JS; - $this->server->evalJS($js); + $out = $this->server->evalJS($js); + if (!empty($out)) { + throw new DriverException(sprintf('Error when loading page %s: %s', $url, $out)); + } } /** From 5d5199d9b290e01be5e61241f83071d3745340fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Terje=20Br=C3=A5ten?= Date: Mon, 14 May 2018 10:11:00 +0100 Subject: [PATCH 2/2] Decode the json encoded error string when throwing exception. --- src/ZombieDriver.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ZombieDriver.php b/src/ZombieDriver.php index 42e25b5..531cfbe 100644 --- a/src/ZombieDriver.php +++ b/src/ZombieDriver.php @@ -127,7 +127,7 @@ public function visit($url) JS; $out = $this->server->evalJS($js); if (!empty($out)) { - throw new DriverException(sprintf('Error when loading page %s: %s', $url, $out)); + throw new DriverException(sprintf('Error when loading page %s: %s', $url, json_decode($out))); } }