From 3bf076db5811710f9d2142809037d85102dd8aad Mon Sep 17 00:00:00 2001 From: Peter Philipp Date: Fri, 28 Jun 2024 09:45:08 +0200 Subject: [PATCH 1/2] dragTo should trigger mouseOver before drop --- src/Selenium2Driver.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index f42ae402..48d74c22 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -870,6 +870,7 @@ public function dragTo(string $sourceXpath, string $destinationXpath) $this->getWebDriverSession()->moveto(array( 'element' => $destination->getID() )); + $this->mouseOver($destinationXpath); $this->getWebDriverSession()->buttonup(); $script = << Date: Fri, 28 Jun 2024 10:24:51 +0200 Subject: [PATCH 2/2] dragTo: Add re-fetch of destination to avoid getting stale element --- src/Selenium2Driver.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 48d74c22..0bc7aa49 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -883,6 +883,8 @@ public function dragTo(string $sourceXpath, string $destinationXpath) element.dispatchEvent(event); }({{ELEMENT}})); JS; + // Re-fetch destination in case mouseOver would make it stale. + $destination = $this->findElement($destinationXpath); $this->withSyn()->executeJsOnElement($destination, $script); }