diff --git a/src/Selenium2Driver.php b/src/Selenium2Driver.php index 058af02c..3f87b638 100755 --- a/src/Selenium2Driver.php +++ b/src/Selenium2Driver.php @@ -843,14 +843,10 @@ public function click(string $xpath) private function clickOnElement(Element $element): void { - if ($this->isW3C()) { - $element->click(); - } - else { - // Move the mouse to the element as Selenium does not allow clicking on an element which is outside the viewport - $this->getWebDriverSession()->moveto(array('element' => $element->getID())); - $element->click(); - } + // Move the mouse to the element as Selenium does not allow clicking on an element which is outside the viewport + $this->doMouseOver($element); + + $element->click(); } public function doubleClick(string $xpath) @@ -938,6 +934,11 @@ public function isVisible(string $xpath) } public function mouseOver(string $xpath) + { + $this->doMouseOver($this->findElement($xpath)); + } + + private function doMouseOver(Element $element) { if ($this->isW3C()) { $actions = array( @@ -947,7 +948,7 @@ public function mouseOver(string $xpath) 'id' => 'mouse1', 'parameters' => ['pointerType' => 'mouse'], 'actions' => [ - ['type' => 'pointerMove', 'duration' => 0, 'origin' => [Element::WEB_ELEMENT_ID => $this->findElement($xpath)->getID()], 'x' => 0, 'y' => 0], + ['type' => 'pointerMove', 'duration' => 0, 'origin' => [Element::WEB_ELEMENT_ID => $element->getID()], 'x' => 0, 'y' => 0], ], ], ], @@ -957,7 +958,7 @@ public function mouseOver(string $xpath) } else { $this->getWebDriverSession()->moveto(array( - 'element' => $this->findElement($xpath)->getID() + 'element' => $element->getID() )); } }