Skip to content

Commit

Permalink
Merge pull request #9 from alexpott/TASK-BC-click
Browse files Browse the repository at this point in the history
Make w3c and non-w3c click work the same
  • Loading branch information
justafish authored Jul 17, 2024
2 parents 4de3353 + 7ad8d80 commit 9144589
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -855,14 +855,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)
Expand Down Expand Up @@ -950,6 +946,11 @@ public function isVisible(string $xpath)
}

public function mouseOver(string $xpath)
{
$this->doMouseOver($this->findElement($xpath));
}

private function doMouseOver(Element $element): void
{
if ($this->isW3C()) {
$actions = array(
Expand All @@ -959,7 +960,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],
],
],
],
Expand All @@ -969,7 +970,7 @@ public function mouseOver(string $xpath)
}
else {
$this->getWebDriverSession()->moveto(array(
'element' => $this->findElement($xpath)->getID()
'element' => $element->getID()
));
}
}
Expand Down

0 comments on commit 9144589

Please sign in to comment.