Skip to content

Commit

Permalink
MDL-46891 behat: Driver specific fixes.
Browse files Browse the repository at this point in the history
1. Browserkit doesn't handle [] in name
2. Grades are not visible in viewport and might fail
   with few drivers, increasing size of window to ensure
   grades are visible and can be modified.
3. Click edit first to see grade link
4. Expand fields before setting value
5. Updated xpath, as crawler update it.
6. Hover fails to show icon
  • Loading branch information
Rajesh Taneja committed Mar 11, 2016
1 parent b73e504 commit e01012e
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 27 deletions.
1 change: 0 additions & 1 deletion admin/tool/behat/tests/behat/manipulate_forms.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Feature: Forms manipulation
When I set the field "First name" to "Field value"
And I set the field "Select a country" to "Japan"
And I set the field "Unmask" to "1"
And I expand all fieldsets
Then the field "First name" matches value "Field value"
And the "Select a country" select box should contain "Japan"
And the field "Unmask" matches value "1"
Expand Down
2 changes: 2 additions & 0 deletions grade/tests/behat/grade_aggregation.feature
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Feature: We can use calculated grade totals
And I follow "Course 1"
And I navigate to "Grades" node in "Course administration"
And I turn editing mode on
And I change window size to "large"
And I give the grade "60.00" to the user "Student 1" for the grade item "Test assignment one"
And I give the grade "20.00" to the user "Student 1" for the grade item "Test assignment two"
And I give the grade "40.00" to the user "Student 1" for the grade item "Test assignment three"
Expand All @@ -58,6 +59,7 @@ Feature: We can use calculated grade totals
| Hidden | 1 |
And I set the following settings for grade item "Test assignment eight":
| Hidden | 1 |
And I change window size to "medium"
And I navigate to "Course grade settings" node in "Grade administration > Setup"
And I set the field "Grade display type" to "Real (percentage)"
And I press "Save changes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@ Feature: Atto accessibility checker
And I wait "2" seconds
And I click on "Image" "button"
And the field "Enter URL" matches value "/broken-image"
And I set the field "Describe this image" to "No more warning!"
And I set the field "Describe this image for someone who cannot see it" to "No more warning!"
And I press "Save image"
And I press "Accessibility checker"
And I should see "Congratulations, no accessibility problems found!"
And I click on ".moodle-dialogue-focused .closebutton" "css_element"
And I select the text in the "Description" Atto editor
And I click on "Image" "button"
And I set the field "Describe this image" to ""
And I set the field "Describe this image for someone who cannot see it" to ""
And I set the field "Description not necessary" to "1"
And I press "Save image"
And I press "Accessibility checker"
Expand Down
6 changes: 3 additions & 3 deletions lib/editor/atto/plugins/image/tests/behat/image.feature
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Feature: Add images to Atto
And I click on "Private files" "link"
And I click on "moodle-logo.png" "link"
And I click on "Select this file" "button"
And I set the field "Describe this image" to "It's the Moodle"
And I set the field "Describe this image for someone who cannot see it" to "It's the Moodle"
# Wait for the page to "settle".
And I wait until the page is ready
And the field "Width" matches value "204"
Expand Down Expand Up @@ -45,7 +45,7 @@ Feature: Add images to Atto
And I follow "Edit profile"
And I select the text in the "Description" Atto editor
And I click on "Image" "button"
Then the field "Describe this image" matches value "It's the Moodle"
Then the field "Describe this image for someone who cannot see it" matches value "It's the Moodle"
And the field "Width" matches value "123"
And the field "Height" matches value "456"

Expand All @@ -58,7 +58,7 @@ Feature: Add images to Atto
And I select the text in the "Description" Atto editor
When I click on "Image" "button"
Then the field "Enter URL" matches value "/nothing/here"
And I set the field "Describe this image" to "Something"
And I set the field "Describe this image for someone who cannot see it" to "Something"
And I set the field "Enter URL" to ""
And I press "Save image"
And I set the field "Description" to "<p>Image: <img src='/nothing/again' width='123' height='456' alt='Awesome!'>.</p>"
Expand Down
4 changes: 3 additions & 1 deletion lib/tests/behat/behat_general.php
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,9 @@ public function row_column_of_table_should_contain($row, $column, $table, $value

// Check if value exists in specific row/column.
// Get row xpath.
$rowxpath = $tablexpath."/tbody/tr[th[normalize-space(.)=" . $rowliteral . "] or td[normalize-space(.)=" . $rowliteral . "]]";
// GoutteDriver uses DomCrawler\Crawler and it is making XPath relative to the current context, so use descendant.
$rowxpath = $tablexpath."/tbody/tr[descendant::th[normalize-space(.)=" . $rowliteral .
"] | descendant::td[normalize-space(.)=" . $rowliteral . "]]";

$columnvaluexpath = $rowxpath . $columnpositionxpath . "[contains(normalize-space(.)," . $valueliteral . ")]";

Expand Down
10 changes: 5 additions & 5 deletions message/tests/behat/delete_messages.feature
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ Feature: Check that messages can be deleted
And "Delete" "link" should exist in the "#message_1" "css_element"
And "Delete" "link" should exist in the "#message_2" "css_element"
# Confirm that there is a confirmation box before deleting, and that when we cancel the messages remain.
And I hover "#message_2" "css_element"
And I click on "#message_2" "css_element"
And I click on "Delete" "link" in the "#message_2" "css_element"
And I press "Cancel"
And I should see "Hey bud, what's happening?"
And I should see "Whoops, forgot to mention that I drank all your beers. Lol."
# Confirm we can delete a message and then can no longer see it.
And I hover "#message_2" "css_element"
And I click on "#message_2" "css_element"
And I click on "Delete" "link" in the "#message_2" "css_element"
And I press "Delete"
And I should see "Hey bud, what's happening?"
Expand Down Expand Up @@ -69,10 +69,10 @@ Feature: Check that messages can be deleted
And "Delete" "link" should exist in the "#message_3" "css_element"
And "Delete" "link" should exist in the "#message_4" "css_element"
# Now, delete one of the messages that User 1 sent and one by User 2.
And I hover "#message_1" "css_element"
And I click on "#message_1" "css_element"
And I click on "Delete" "link" in the "#message_1" "css_element"
And I press "Delete"
And I hover "#message_2" "css_element"
And I click on "#message_2" "css_element"
And I click on "Delete" "link" in the "#message_2" "css_element"
And I press "Delete"
# Confirm that the messages are no longer listed.
Expand Down Expand Up @@ -111,7 +111,7 @@ Feature: Check that messages can be deleted
# Send a message from the admin to User 1
And I send "Hey there, this is the all-powerful administrator. Obey my commands." message to "User 1" user
# Check the admin is still able to delete messages.
And I hover "#message_1" "css_element"
And I click on "#message_1" "css_element"
And I click on "Delete" "link" in the "#message_1" "css_element"
And I press "Delete"
And I should not see "Hey there, this is the all-powerful administrator. Obey my commands."
Expand Down
2 changes: 2 additions & 0 deletions mod/assign/feedback/editpdf/tests/behat/annotate_pdf.feature
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ Feature: In an assignment, teacher can annotate PDF files during grading
And I follow "Course 1"
And I follow "Test assignment name"
And I follow "View/grade all submissions"
And I click on "Edit" "link" in the "Submitted for grading" "table_row"
And I click on "Grade" "link" in the "Submitted for grading" "table_row"
And I follow "Launch PDF editor..."
And I change window size to "large"
Expand Down Expand Up @@ -129,6 +130,7 @@ Feature: In an assignment, teacher can annotate PDF files during grading
And I follow "Course 1"
And I follow "Test assignment name"
And I follow "View/grade all submissions"
And I click on "Edit" "link" in the "Student 2" "table_row"
And I click on "Grade" "link" in the "Student 2" "table_row"
And I follow "Launch PDF editor..."
And I change window size to "large"
Expand Down
2 changes: 1 addition & 1 deletion mod/assign/tests/behat/comment_inline.feature
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ Feature: In an assignment, teachers can edit a students submission inline
| assignsubmission_onlinetext_enabled | 1 |
| assignsubmission_file_enabled | 0 |
| assignfeedback_comments_enabled | 1 |
| assignfeedback_comments_commentinline | 1 |
| assignfeedback_file_enabled | 1 |
| assignfeedback_comments_commentinline | 1 |
And I log out
And I log in as "student1"
And I follow "Course 1"
Expand Down
6 changes: 2 additions & 4 deletions mod/data/tests/behat/required_entries.feature
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ Feature: Users can be required to specify certain fields when adding entries to
| Required | yes |
| Options | Required Checkbox Option 1 |
And I follow "Fields"
And I set the field "newtype" to "Checkbox"
And I click on "Go" "button" in the ".fieldadd" "css_element"
And I select "Checkbox" from the "newtype" singleselect
And I set the following fields to these values:
| Field name | Required Two-Option Checkbox |
| Field description | Required Two-Option Checkbox |
Expand Down Expand Up @@ -79,8 +78,7 @@ Feature: Users can be required to specify certain fields when adding entries to
| Required | yes |
| Options | Option 1 |
And I follow "Fields"
And I set the field "newtype" to "Multimenu"
And I click on "Go" "button" in the ".fieldadd" "css_element"
And I select "Multimenu" from the "newtype" singleselect
And I set the following fields to these values:
| Field name | Required Two-Option Multimenu |
| Field description | Required Two-Option Multimenu |
Expand Down
7 changes: 4 additions & 3 deletions mod/feedback/tests/behat/question_types.feature
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ Feature: Test creating different types of feedback questions
And I should see "C1" in the "(info)" "table"
And I should see "my long answer" in the "(longertext)" "table"
And I should see "lots of feedbacks" in the "(longertext)" "table"
#And I should see "1 (50.00 %)" in the "option a:" "table_row" // TODO: MDL-46891
#And I should see "1 (50.00 %)" in the "option b:" "table_row" // TODO: MDL-46891
And I should see "2 (100.00 %)" in the "option d:" "table_row"
And I should see "1 (50.00 %)" in the "option e:" "table_row"
And I should see "1 (50.00 %)" in the "option f:" "table_row"
Expand All @@ -131,9 +129,12 @@ Feature: Test creating different types of feedback questions
And I should see "Average: 53.00" in the "(numeric)" "table"
And I should see "no way" in the "(shorttext)" "table"
And I should see "hello" in the "(shorttext)" "table"
And I log out

Scenario: Create different types of questions in feedback with javascript disabled
And I log out

@javascript
Scenario: Create different types of questions in feedback with javascript enabled
And I should see "1 (50.00 %)" in the "option a:" "table_row"
And I should see "1 (50.00 %)" in the "option b:" "table_row"
And I log out
3 changes: 3 additions & 0 deletions mod/quiz/tests/behat/settings_form_fields_disableif.feature
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Feature: Settings form fields disabled if not required
| Attempts allowed | 3 |
And I press "Save"
And I navigate to "Edit settings" node in "Quiz administration"
And I expand all fieldsets
And I set the field "Attempts allowed" to "1"
Then the "Grading method" "field" should be enabled
And the "Each attempt builds on the last" "field" should be enabled
Expand All @@ -71,6 +72,7 @@ Feature: Settings form fields disabled if not required
And I set the field "Attempts allowed" to "2"
And I press "Save"
And I navigate to "Edit settings" node in "Quiz administration"
And I expand all fieldsets
And I set the field "Attempts allowed" to "1"
Then the "Grading method" "field" should be enabled
And the "Each attempt builds on the last" "field" should be enabled
Expand All @@ -85,6 +87,7 @@ Feature: Settings form fields disabled if not required
| Attempts allowed | Unlimited |
And I press "Save"
And I navigate to "Edit settings" node in "Quiz administration"
And I expand all fieldsets
And I set the field "Attempts allowed" to "1"
Then the "Grading method" "field" should be enabled
And the "Each attempt builds on the last" "field" should be enabled
Expand Down
5 changes: 3 additions & 2 deletions question/type/ddimageortext/tests/behat/preview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Feature: Preview a drag-drop onto image question
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"
# Keep window large else drag will scroll the window to find element.
And I change window size to "large"
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
Expand All @@ -50,7 +51,7 @@ Feature: Preview a drag-drop onto image question
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 change window size to "large"
And I wait "2" seconds
And I type " " on place "1" in the drag and drop onto image question
And I type " " on place "2" in the drag and drop onto image question
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function i_drag_to_in_the_drag_and_drop_markers_question($marker, $coordi
// Therefore to make it drag to the specified place, we have to add
// a target div.
$session = $this->getSession();
$session->evaluateScript("
$session->executeScript("
(function() {
if (document.getElementById('target-{$x}-{$y}')) {
return;
Expand Down
6 changes: 4 additions & 2 deletions question/type/ddmarker/tests/behat/preview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Feature: Preview a drag-drop onto image question
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"
# Keep window large else drag will scroll the window to find element.
And I change window size to "large"
And I wait "2" seconds
# Odd, but the <br>s go to nothing, not a space.
And I drag "OU" to "342,230" in the drag and drop markers question
Expand All @@ -46,7 +47,8 @@ Feature: Preview a drag-drop onto image question
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"
# Keep window large else drag will scroll the window to find element.
And I change window size to "large"
And I wait "2" seconds
And I type "up" "89" times on marker "Railway station" in the drag and drop markers question
And I type "right" "21" times on marker "Railway station" in the drag and drop markers question
Expand Down
3 changes: 2 additions & 1 deletion question/type/ddwtos/tests/behat/preview.feature
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ Feature: Preview a drag-drop into text question
When I click on "Preview" "link" in the "Drag to text" "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"
# Keep window large else drag will scroll the window to find element.
And I change window size to "large"
And I wait "2" seconds
And I drag "quick" to space "1" in the drag and drop into text question
And I drag "fox" to space "2" in the drag and drop into text question
Expand Down
4 changes: 3 additions & 1 deletion repository/tests/behat/behat_filepicker.php
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,9 @@ protected function add_file_from_repository_to_filemanager($filepath, $repositor
$field->set_value($value);
}

$this->find_button(get_string('getfile', 'repository'))->click();
$selectfilebutton = $this->find_button(get_string('getfile', 'repository'));
$this->ensure_node_is_visible($selectfilebutton);
$selectfilebutton->click();

// We wait for all the JS to finish as it is performing an action.
$this->getSession()->wait(self::TIMEOUT, self::PAGE_READY_JS);
Expand Down

0 comments on commit e01012e

Please sign in to comment.