From d2ee22e7447dd8a630c1369617850edca4d8c317 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja Date: Thu, 10 Mar 2016 16:26:04 +0800 Subject: [PATCH] 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 --- lib/behat/form_field/behat_form_autocomplete.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/behat/form_field/behat_form_autocomplete.php b/lib/behat/form_field/behat_form_autocomplete.php index 3bd72493c92..aadfbc1e83b 100644 --- a/lib/behat/form_field/behat_form_autocomplete.php +++ b/lib/behat/form_field/behat_form_autocomplete.php @@ -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); -- 2.11.4.GIT