MDL-47494 qtype: Fix the behat tests for OU dd question types
[moodle.git] / question / type / ddimageortext / tests / behat / behat_qtype_ddimageortext.php
index a1a5239..879b665 100644 (file)
@@ -60,7 +60,6 @@ class behat_qtype_ddimageortext extends behat_base {
      * @param int $placenumber the number of the place to drop into.
      *
      * @Given /^I drag "(?P<drag_item>[^"]*)" to place "(?P<place_number>\d+)" in the drag and drop onto image question$/
-     * 
      */
     public function i_drag_to_place_in_the_drag_and_drop_onto_image_question($dragitem, $placenumber) {
         $generalcontext = behat_context_helper::get('behat_general');
@@ -77,7 +76,12 @@ class behat_qtype_ddimageortext extends behat_base {
      * @Given /^I type "(?P<keys>[^"]*)" on place "(?P<place_number>\d+)" in the drag and drop onto image question$/
      */
     public function i_type_on_place_in_the_drag_and_drop_onto_image_question($keys, $placenumber) {
-        $generalcontext = behat_context_helper::get('behat_general');
-        $generalcontext->i_type_into_the($keys, $this->drop_xpath($placenumber), 'xpath_element');
+        $node = $this->get_selected_node('xpath_element', $this->drop_xpath($placenumber));
+        $this->ensure_node_is_visible($node);
+        foreach (str_split($keys) as $key) {
+            $node->keyDown($key);
+            $node->keyPress($key);
+            $node->keyUp($key);
+        }
     }
 }