Merge branch 'MDL-64570-master' of git://github.com/damyon/moodle
[moodle.git] / lib / behat / form_field / behat_form_field.php
index f5b87ab..bb011e0 100644 (file)
@@ -182,6 +182,20 @@ class behat_form_field {
         return get_class($this->session->getDriver()) !== 'Behat\Mink\Driver\GoutteDriver';
     }
 
+    /**
+     * Waits for all the JS activity to be completed.
+     *
+     * @return bool Whether any JS is still pending completion.
+     */
+    protected function wait_for_pending_js() {
+        if (!$this->running_javascript()) {
+            // JS is not available therefore there is nothing to wait for.
+            return false;
+        }
+
+        return behat_base::wait_for_pending_js_in_session($this->session);
+    }
+
     /**
      * Gets the field internal id used by selenium wire protocol.
      *