diff --git a/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php b/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php index 15c38801d6b7e..4f58e7e0a6d00 100644 --- a/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php +++ b/question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php @@ -78,10 +78,11 @@ public function i_drag_to_place_in_the_drag_and_drop_onto_image_question($dragit public function i_type_on_place_in_the_drag_and_drop_onto_image_question($keys, $placenumber) { $node = $this->get_selected_node('xpath_element', $this->drop_xpath($placenumber)); $this->ensure_node_is_visible($node); + + $node->focus(); foreach (str_split($keys) as $key) { - $node->keyDown($key); - $node->keyPress($key); - $node->keyUp($key); + behat_base::type_keys($this->getSession(), [$key]); + $this->wait_for_pending_js(); } } } diff --git a/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php b/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php index d498e4350572e..73599d263517c 100644 --- a/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php +++ b/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php @@ -107,19 +107,12 @@ public function i_drag_to_in_the_drag_and_drop_markers_question($marker, $coordi * @Given /^I type "(?Pup|down|left|right)" "(?P\d+)" times on marker "(?P[^"]*)" in the drag and drop markers question$/ */ public function i_type_on_marker_in_the_drag_and_drop_markers_question($direction, $repeats, $marker) { - $keycodes = array( - 'up' => chr(38), - 'down' => chr(40), - 'left' => chr(37), - 'right' => chr(39), - ); list($marker, $item) = $this->parse_marker_name($marker); $node = $this->get_selected_node('xpath_element', $this->marker_xpath($marker, $item)); $this->ensure_node_is_visible($node); + $node->focus(); for ($i = 0; $i < $repeats; $i++) { - $node->keyDown($keycodes[$direction]); - $node->keyPress($keycodes[$direction]); - $node->keyUp($keycodes[$direction]); + $this->execute('behat_general::i_press_named_key', ['', $direction]); } } } diff --git a/question/type/ddwtos/tests/behat/behat_qtype_ddwtos.php b/question/type/ddwtos/tests/behat/behat_qtype_ddwtos.php index 2cc46083df12a..142c0da548028 100644 --- a/question/type/ddwtos/tests/behat/behat_qtype_ddwtos.php +++ b/question/type/ddwtos/tests/behat/behat_qtype_ddwtos.php @@ -78,10 +78,10 @@ public function i_drag_to_space_in_the_drag_and_drop_into_text_question($dragite public function i_type_into_space_in_the_drag_and_drop_into_text_question($keys, $spacenumber) { $node = $this->get_selected_node('xpath_element', $this->drop_xpath($spacenumber)); $this->ensure_node_is_visible($node); + $node->focus(); foreach (str_split($keys) as $key) { - $node->keyDown($key); - $node->keyPress($key); - $node->keyUp($key); + behat_base::type_keys($this->getSession(), [$key]); + $this->wait_for_pending_js(); } } }