From 45b0f89d87bb66186ef7374e5d5fecdc1b4015b1 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Fri, 26 Jun 2020 21:18:24 +0800 Subject: [PATCH] MDL-66979 behat: Scroll nodes into view before hover The W3C Specification does not require that a NodeElement be in the current viewport before triggering a mouseOver. As a result the mouseOver will generate an Exception because the element is not in the viewport, and the X/Y co-ordinates are invalid. To handle this the node is scrolled into view. --- lib/tests/behat/behat_general.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index 0f555d56b57..effa94ce047 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -346,9 +346,9 @@ class behat_general extends behat_base { * @param string $selectortype The type of what we look for */ public function i_hover($element, $selectortype) { - // Gets the node based on the requested selector type and locator. $node = $this->get_selected_node($selectortype, $element); + $this->execute_js_on_node($node, '{{ELEMENT}}.scrollIntoView();'); $node->mouseOver(); }