MDL-27628 behat: Added delay to ensure the value is set.
[moodle.git] / lib / behat / form_field / behat_form_autocomplete.php
index 3bd7249..aadfbc1 100644 (file)
@@ -48,6 +48,9 @@ class behat_form_autocomplete extends behat_form_text {
             throw new coding_exception('Setting the valid of an autocomplete field requires javascript.');
         }
         $this->field->setValue($value);
+        // After the value is set, there is a 400ms throttle and then search. So adding 2 sec. delay to ensure both
+        // throttle + search finishes.
+        sleep(2);
         $id = $this->field->getAttribute('id');
         $js = ' require(["jquery"], function($) { $(document.getElementById("'.$id.'")).trigger("behat:set-value"); }); ';
         $this->session->executeScript($js);