MDL-27628 behat: Added delay to ensure the value is set.
authorRajesh Taneja <rajesh@moodle.com>
Thu, 10 Mar 2016 08:26:04 +0000 (16:26 +0800)
committerEloy Lafuente (stronk7) <stronk7@moodle.org>
Thu, 10 Mar 2016 12:17:11 +0000 (13:17 +0100)
After user type there is a 400ms delay, then search
Adding 2 sec delay to ensure search is finished before
click event is triggred

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);