MDL-27628 behat: Added delay to ensure the value is set.

After user type there is a 400ms delay, then search
Adding 2 sec delay to ensure search is finished before
click event is triggred
This commit is contained in:
Rajesh Taneja
2016-03-10 13:17:11 +01:00
committed by Eloy Lafuente (stronk7)
parent 9621d5a7ae
commit d2ee22e744
@@ -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);