MDL-51555 behat: Increase question preview window
authorrajesh Taneja <rajesh@moodle.com>
Fri, 25 Sep 2015 03:50:51 +0000 (11:50 +0800)
committerrajesh Taneja <rajesh@moodle.com>
Fri, 25 Sep 2015 08:53:14 +0000 (16:53 +0800)
As question preview window is small, chrome driver
fails to select drag and drop element

question/type/ddimageortext/tests/behat/preview.feature
question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php
question/type/ddmarker/tests/behat/preview.feature

index 5fd1d31..6f1c94d 100644 (file)
@@ -28,6 +28,9 @@ Feature: Preview a drag-drop onto image question
   Scenario: Preview a question using the mouse.
     When I click on "Preview" "link" in the "Drag onto image" "table_row"
     And I switch to "questionpreview" window
+    # Increase window size and wait 2 seconds to ensure elements are placed properly by js.
+    And I change window size to "medium"
+    And I wait "2" seconds
     # Odd, but the <br>s go to nothing, not a space.
     And I drag "mountainbelt" to place "1" in the drag and drop onto image question
     And I drag "continentalshelf" to place "2" in the drag and drop onto image question
index 23ec698..4bd57fc 100644 (file)
@@ -83,10 +83,11 @@ class behat_qtype_ddmarker extends behat_base {
                     var container = document.querySelector('.droparea');
                     container.style.setProperty('position', 'relative');
                     container.insertBefore(target, image);
-                    var xadjusted = {$x} + (container.offsetWidth - image.offsetWidth) / 2
+                    var xadjusted = {$x} + (container.offsetWidth - image.offsetWidth) / 2;
+                    var yadjusted = {$y} + (container.offsetHeight - image.offsetHeight) / 2;
                     target.style.setProperty('position', 'absolute');
                     target.style.setProperty('left', xadjusted + 'px');
-                    target.style.setProperty('top', '{$y}px');
+                    target.style.setProperty('top', yadjusted + 'px');
                     target.style.setProperty('width', '1px');
                     target.style.setProperty('height', '1px');
                 }())");
index e6a52d9..be93232 100644 (file)
@@ -28,11 +28,14 @@ Feature: Preview a drag-drop onto image question
   Scenario: Preview a question using the mouse.
     When I click on "Preview" "link" in the "Drag markers" "table_row"
     And I switch to "questionpreview" window
+    # Increase window size and wait 2 seconds to ensure elements are placed properly by js.
+    And I change window size to "medium"
+    And I wait "2" seconds
     # Odd, but the <br>s go to nothing, not a space.
-    And I drag "OU" to "340,228" in the drag and drop markers question
-    And I drag "Railway station" to "252,195" in the drag and drop markers question
-    And I drag "Railway station,1" to "324,317" in the drag and drop markers question
-    And I drag "Railway station,2" to "201,99" in the drag and drop markers question
+    And I drag "OU" to "342,230" in the drag and drop markers question
+    And I drag "Railway station" to "254,197" in the drag and drop markers question
+    And I drag "Railway station,1" to "326,319" in the drag and drop markers question
+    And I drag "Railway station,2" to "203,101" in the drag and drop markers question
     And I press "Submit and finish"
     Then the state of "Please place the markers on the map of Milton Keynes" question is shown as "Correct"
     And I should see "Mark 1.00 out of 1.00"