Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move mouse in W3C and non-W3C mode before clicking #6

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions src/Selenium2Driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -938,6 +934,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 @@ -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],
],
],
],
Expand All @@ -957,7 +958,7 @@ public function mouseOver(string $xpath)
}
else {
$this->getWebDriverSession()->moveto(array(
'element' => $this->findElement($xpath)->getID()
'element' => $element->getID()
));
}
}
Expand Down
Loading