Skip to content

Commit 739b757

Browse files
authored
Merge pull request #255 from stof/better_geckodriver_support
Improve compatibility with GeckoDriver when using Selenium 3
2 parents cda2344 + 7aa0e14 commit 739b757

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/Selenium2Driver.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use Behat\Mink\Selector\Xpath\Escaper;
1515
use WebDriver\Element;
1616
use WebDriver\Exception\NoSuchElement;
17+
use WebDriver\Exception\UnknownCommand;
1718
use WebDriver\Exception\UnknownError;
1819
use WebDriver\Exception;
1920
use WebDriver\Key;
@@ -764,7 +765,13 @@ public function click($xpath)
764765

765766
private function clickOnElement(Element $element)
766767
{
767-
$this->wdSession->moveto(array('element' => $element->getID()));
768+
try {
769+
// Move the mouse to the element as Selenium does not allow clicking on an element which is outside the viewport
770+
$this->wdSession->moveto(array('element' => $element->getID()));
771+
} catch (UnknownCommand $e) {
772+
// If the Webdriver implementation does not support moveto (which is not part of the W3C WebDriver spec), proceed to the click
773+
}
774+
768775
$element->click();
769776
}
770777

0 commit comments

Comments
 (0)