MDL-51555 behat: Increase question preview window

As question preview window is small, chrome driver
fails to select drag and drop element
This commit is contained in:
rajesh Taneja 2015-09-25 11:50:51 +08:00
parent 8d892b1d40
commit 0f2aad5908
3 changed files with 13 additions and 6 deletions

View 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

View 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');
}())");

View 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"