MDL-47494 qtype: Fix the behat tests for OU dd question types
authorDamyon Wiese <damyon@moodle.com>
Fri, 11 Sep 2015 06:04:58 +0000 (14:04 +0800)
committerTim Hunt <T.J.Hunt@open.ac.uk>
Fri, 18 Sep 2015 06:56:27 +0000 (07:56 +0100)
lib/tests/behat/behat_general.php
question/type/ddimageortext/tests/behat/behat_qtype_ddimageortext.php
question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php

index 04398d7..bd0d4ff 100644 (file)
@@ -411,6 +411,15 @@ class behat_general extends behat_base {
         list($containerselector, $containerlocator) = $this->transform_selector($containerselectortype, $containerelement);
         $destinationxpath = $this->getSession()->getSelectorsHandler()->selectorToXpath($containerselector, $containerlocator);
 
+        $node = $this->get_selected_node("xpath_element", $sourcexpath);
+        if (!$node->isVisible()) {
+            throw new ExpectationException('"' . $sourcexpath . '" "xpath_element" is not visible', $this->getSession());
+        }
+        $node = $this->get_selected_node("xpath_element", $destinationxpath);
+        if (!$node->isVisible()) {
+            throw new ExpectationException('"' . $destinationxpath . '" "xpath_element" is not visible', $this->getSession());
+        }
+
         $this->getSession()->getDriver()->dragTo($sourcexpath, $destinationxpath);
     }
 
index b5b3e94..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');
index cb800cc..23ec698 100644 (file)
@@ -71,7 +71,6 @@ class behat_qtype_ddmarker extends behat_base {
         // DOM node so that its centre is over the centre of anothe DOM node.
         // Therefore to make it drag to the specified place, we have to add
         // a target div.
-        $style = 
         $session = $this->getSession();
         $session->evaluateScript("
                 (function() {
@@ -88,8 +87,8 @@ class behat_qtype_ddmarker extends behat_base {
                     target.style.setProperty('position', 'absolute');
                     target.style.setProperty('left', xadjusted + 'px');
                     target.style.setProperty('top', '{$y}px');
-                    target.style.setProperty('width', '0');
-                    target.style.setProperty('height', '0');
+                    target.style.setProperty('width', '1px');
+                    target.style.setProperty('height', '1px');
                 }())");
 
         $generalcontext = behat_context_helper::get('behat_general');