diff --git a/src/Moodle/BehatExtension/Element/NodeElement.php b/src/Moodle/BehatExtension/Element/NodeElement.php index 1c729d0..0d82987 100644 --- a/src/Moodle/BehatExtension/Element/NodeElement.php +++ b/src/Moodle/BehatExtension/Element/NodeElement.php @@ -25,6 +25,7 @@ namespace Moodle\BehatExtension\Element; use Behat\Mink\Element\NodeElement as MinkNodeElement; +use Facebook\WebDriver\Exception\NoSuchWindowException; /** * Node Element. @@ -46,7 +47,20 @@ public function click() { $this->ensure_node_is_in_viewport(); } - parent::click(); + try { + parent::click(); + } catch (ElementNotInteractableException $e) { + // There is a bug in Geckodriver which means that it is unable to click any link which contains a block + // level node. See https://github.com/mozilla/geckodriver/issues/653. + // The workaround is to click on it's first descendant instead. + if ($child = $this->find('xpath', './*[1]')) { + $child->click(); + + return; + } + + throw $e; + } }