MDL-55258 behat: Set focus on button before clicking it
authorRajesh Taneja <rajesh@moodle.com>
Tue, 19 Jul 2016 01:23:44 +0000 (09:23 +0800)
committerRajesh Taneja <rajesh@moodle.com>
Tue, 19 Jul 2016 01:23:44 +0000 (09:23 +0800)
Set the focus on button to ensure it is in
viewport before clicking on it.

lib/tests/behat/behat_forms.php

index 2345962..d681d2c 100644 (file)
@@ -54,6 +54,10 @@ class behat_forms extends behat_base {
 
         // Ensures the button is present.
         $buttonnode = $this->find_button($button);
+        // Focus on button to ensure it is in viewport, before pressing it.
+        if ($this->running_javascript()) {
+            $buttonnode->focus();
+        }
         $buttonnode->press();
     }