@@ -50,8 +50,6 @@ public function __construct(WebDriver $driver, WebDriverDispatcher $dispatcher =
5050 $ this ->dispatcher ->setDefaultDriver ($ this );
5151 }
5252 $ this ->driver = $ driver ;
53-
54- return $ this ;
5553 }
5654
5755 /**
@@ -105,6 +103,7 @@ public function get($url)
105103 $ this ->driver ->get ($ url );
106104 } catch (WebDriverException $ exception ) {
107105 $ this ->dispatchOnException ($ exception );
106+ throw $ exception ;
108107 }
109108 $ this ->dispatch ('afterNavigateTo ' , $ url , $ this );
110109
@@ -127,6 +126,7 @@ public function findElements(WebDriverBy $by)
127126 }
128127 } catch (WebDriverException $ exception ) {
129128 $ this ->dispatchOnException ($ exception );
129+ throw $ exception ;
130130 }
131131
132132 $ this ->dispatch ('afterFindBy ' , $ by , null , $ this );
@@ -147,6 +147,7 @@ public function findElement(WebDriverBy $by)
147147 $ element = $ this ->newElement ($ this ->driver ->findElement ($ by ));
148148 } catch (WebDriverException $ exception ) {
149149 $ this ->dispatchOnException ($ exception );
150+ throw $ exception ;
150151 }
151152
152153 $ this ->dispatch ('afterFindBy ' , $ by , null , $ this );
@@ -174,6 +175,7 @@ public function executeScript($script, array $arguments = [])
174175 $ result = $ this ->driver ->executeScript ($ script , $ arguments );
175176 } catch (WebDriverException $ exception ) {
176177 $ this ->dispatchOnException ($ exception );
178+ throw $ exception ;
177179 }
178180
179181 $ this ->dispatch ('afterScript ' , $ script , $ this );
@@ -200,6 +202,7 @@ public function executeAsyncScript($script, array $arguments = [])
200202 $ result = $ this ->driver ->executeAsyncScript ($ script , $ arguments );
201203 } catch (WebDriverException $ exception ) {
202204 $ this ->dispatchOnException ($ exception );
205+ throw $ exception ;
203206 }
204207 $ this ->dispatch ('afterScript ' , $ script , $ this );
205208
@@ -218,6 +221,7 @@ public function close()
218221 return $ this ;
219222 } catch (WebDriverException $ exception ) {
220223 $ this ->dispatchOnException ($ exception );
224+ throw $ exception ;
221225 }
222226 }
223227
@@ -231,6 +235,7 @@ public function getCurrentURL()
231235 return $ this ->driver ->getCurrentURL ();
232236 } catch (WebDriverException $ exception ) {
233237 $ this ->dispatchOnException ($ exception );
238+ throw $ exception ;
234239 }
235240 }
236241
@@ -244,6 +249,7 @@ public function getPageSource()
244249 return $ this ->driver ->getPageSource ();
245250 } catch (WebDriverException $ exception ) {
246251 $ this ->dispatchOnException ($ exception );
252+ throw $ exception ;
247253 }
248254 }
249255
@@ -257,6 +263,7 @@ public function getTitle()
257263 return $ this ->driver ->getTitle ();
258264 } catch (WebDriverException $ exception ) {
259265 $ this ->dispatchOnException ($ exception );
266+ throw $ exception ;
260267 }
261268 }
262269
@@ -270,6 +277,7 @@ public function getWindowHandle()
270277 return $ this ->driver ->getWindowHandle ();
271278 } catch (WebDriverException $ exception ) {
272279 $ this ->dispatchOnException ($ exception );
280+ throw $ exception ;
273281 }
274282 }
275283
@@ -283,6 +291,7 @@ public function getWindowHandles()
283291 return $ this ->driver ->getWindowHandles ();
284292 } catch (WebDriverException $ exception ) {
285293 $ this ->dispatchOnException ($ exception );
294+ throw $ exception ;
286295 }
287296 }
288297
@@ -295,6 +304,7 @@ public function quit()
295304 $ this ->driver ->quit ();
296305 } catch (WebDriverException $ exception ) {
297306 $ this ->dispatchOnException ($ exception );
307+ throw $ exception ;
298308 }
299309 }
300310
@@ -309,6 +319,7 @@ public function takeScreenshot($save_as = null)
309319 return $ this ->driver ->takeScreenshot ($ save_as );
310320 } catch (WebDriverException $ exception ) {
311321 $ this ->dispatchOnException ($ exception );
322+ throw $ exception ;
312323 }
313324 }
314325
@@ -324,6 +335,7 @@ public function wait($timeout_in_second = 30, $interval_in_millisecond = 250)
324335 return $ this ->driver ->wait ($ timeout_in_second , $ interval_in_millisecond );
325336 } catch (WebDriverException $ exception ) {
326337 $ this ->dispatchOnException ($ exception );
338+ throw $ exception ;
327339 }
328340 }
329341
@@ -337,6 +349,7 @@ public function manage()
337349 return $ this ->driver ->manage ();
338350 } catch (WebDriverException $ exception ) {
339351 $ this ->dispatchOnException ($ exception );
352+ throw $ exception ;
340353 }
341354 }
342355
@@ -353,6 +366,7 @@ public function navigate()
353366 );
354367 } catch (WebDriverException $ exception ) {
355368 $ this ->dispatchOnException ($ exception );
369+ throw $ exception ;
356370 }
357371 }
358372
@@ -366,6 +380,7 @@ public function switchTo()
366380 return $ this ->driver ->switchTo ();
367381 } catch (WebDriverException $ exception ) {
368382 $ this ->dispatchOnException ($ exception );
383+ throw $ exception ;
369384 }
370385 }
371386
@@ -379,13 +394,16 @@ public function getTouch()
379394 return $ this ->driver ->getTouch ();
380395 } catch (WebDriverException $ exception ) {
381396 $ this ->dispatchOnException ($ exception );
397+ throw $ exception ;
382398 }
383399 }
384400
385- private function dispatchOnException ($ exception )
401+ /**
402+ * @param WebDriverException $exception
403+ */
404+ private function dispatchOnException (WebDriverException $ exception )
386405 {
387406 $ this ->dispatch ('onException ' , $ exception , $ this );
388- throw $ exception ;
389407 }
390408
391409 public function execute ($ name , $ params )
@@ -394,6 +412,7 @@ public function execute($name, $params)
394412 return $ this ->driver ->execute ($ name , $ params );
395413 } catch (WebDriverException $ exception ) {
396414 $ this ->dispatchOnException ($ exception );
415+ throw $ exception ;
397416 }
398417 }
399418}
0 commit comments