From 6ca447e519517164aa457f6cfa834061ee26a591 Mon Sep 17 00:00:00 2001 From: Anthon Pang Date: Thu, 7 Dec 2023 17:45:53 -0500 Subject: [PATCH] moveto shim to transform ScriptTimeout exception to UnknownError --- lib/WebDriver/Session.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/WebDriver/Session.php b/lib/WebDriver/Session.php index aecb4f5..92c9b16 100644 --- a/lib/WebDriver/Session.php +++ b/lib/WebDriver/Session.php @@ -22,6 +22,8 @@ namespace WebDriver; +use WebDriver\Exception as WebDriverException; + /** * WebDriver\Session class * @@ -292,6 +294,24 @@ public function frame() return new Frame($this->url . '/frame'); } + /** + * moveto: /session/:sessionId/moveto (POST) + * + * @param array $parameters + * + * @return mixed + */ + public function moveto($parameters) + { + try { + $result = $this->curl('POST', '/moveto', $parameters); + } catch (WebDriverException\ScriptTimeout) { + throw WebDriverException::factory(WebDriverException::UNKNOWN_ERROR); + } + + return $result['value']; + } + /** * timeouts methods: /session/:sessionId/timeouts (POST) * - $session->timeouts($json) - set timeout for an operation