From e01012e96d6d46f340280fed8e81dc6f12dceb28 Mon Sep 17 00:00:00 2001 From: Rajesh Taneja <rajesh@moodle.com> Date: Thu, 3 Mar 2016 15:20:37 +0800 Subject: [PATCH] MDL-46891 behat: Driver specific fixes. 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 --- admin/tool/behat/tests/behat/manipulate_forms.feature | 1 - grade/tests/behat/grade_aggregation.feature | 2 ++ .../tests/behat/accessibilitychecker.feature | 4 ++-- .../atto/plugins/image/tests/behat/image.feature | 6 +++--- lib/tests/behat/behat_general.php | 4 +++- message/tests/behat/delete_messages.feature | 10 +++++----- .../feedback/editpdf/tests/behat/annotate_pdf.feature | 2 ++ mod/assign/tests/behat/comment_inline.feature | 2 +- mod/data/tests/behat/required_entries.feature | 6 ++---- mod/feedback/tests/behat/question_types.feature | 7 ++++--- .../tests/behat/settings_form_fields_disableif.feature | 3 +++ .../type/ddimageortext/tests/behat/preview.feature | 5 +++-- .../type/ddmarker/tests/behat/behat_qtype_ddmarker.php | 2 +- question/type/ddmarker/tests/behat/preview.feature | 6 ++++-- question/type/ddwtos/tests/behat/preview.feature | 3 ++- repository/tests/behat/behat_filepicker.php | 4 +++- 16 files changed, 40 insertions(+), 27 deletions(-) diff --git a/admin/tool/behat/tests/behat/manipulate_forms.feature b/admin/tool/behat/tests/behat/manipulate_forms.feature index 20c3c29ab0679..126a800f6bb40 100644 --- a/admin/tool/behat/tests/behat/manipulate_forms.feature +++ b/admin/tool/behat/tests/behat/manipulate_forms.feature @@ -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" diff --git a/grade/tests/behat/grade_aggregation.feature b/grade/tests/behat/grade_aggregation.feature index c51e281b3366b..3e2ab94fe3ff3 100644 --- a/grade/tests/behat/grade_aggregation.feature +++ b/grade/tests/behat/grade_aggregation.feature @@ -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" @@ -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" diff --git a/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature b/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature index 8757b293dda46..478f50e69ad73 100644 --- a/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature +++ b/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature @@ -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" diff --git a/lib/editor/atto/plugins/image/tests/behat/image.feature b/lib/editor/atto/plugins/image/tests/behat/image.feature index b88913669aef8..744831de47a31 100644 --- a/lib/editor/atto/plugins/image/tests/behat/image.feature +++ b/lib/editor/atto/plugins/image/tests/behat/image.feature @@ -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" @@ -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" @@ -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>" diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index c301b0a0c1c7a..6ac017c59a6a2 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -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 . ")]"; diff --git a/message/tests/behat/delete_messages.feature b/message/tests/behat/delete_messages.feature index 0e95f6c93bc84..745618d3eef69 100644 --- a/message/tests/behat/delete_messages.feature +++ b/message/tests/behat/delete_messages.feature @@ -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?" @@ -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. @@ -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." diff --git a/mod/assign/feedback/editpdf/tests/behat/annotate_pdf.feature b/mod/assign/feedback/editpdf/tests/behat/annotate_pdf.feature index 4900960c09ef5..b54baff41a761 100644 --- a/mod/assign/feedback/editpdf/tests/behat/annotate_pdf.feature +++ b/mod/assign/feedback/editpdf/tests/behat/annotate_pdf.feature @@ -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" @@ -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" diff --git a/mod/assign/tests/behat/comment_inline.feature b/mod/assign/tests/behat/comment_inline.feature index d63d098990cc3..13bebcfbadb69 100644 --- a/mod/assign/tests/behat/comment_inline.feature +++ b/mod/assign/tests/behat/comment_inline.feature @@ -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" diff --git a/mod/data/tests/behat/required_entries.feature b/mod/data/tests/behat/required_entries.feature index d5ef8e548a5c2..eab816c8b6bc6 100644 --- a/mod/data/tests/behat/required_entries.feature +++ b/mod/data/tests/behat/required_entries.feature @@ -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 | @@ -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 | diff --git a/mod/feedback/tests/behat/question_types.feature b/mod/feedback/tests/behat/question_types.feature index 585e993c791e5..d6dcbd6410209 100644 --- a/mod/feedback/tests/behat/question_types.feature +++ b/mod/feedback/tests/behat/question_types.feature @@ -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" @@ -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 diff --git a/mod/quiz/tests/behat/settings_form_fields_disableif.feature b/mod/quiz/tests/behat/settings_form_fields_disableif.feature index 0e7213ec67ddc..587e84b78096c 100644 --- a/mod/quiz/tests/behat/settings_form_fields_disableif.feature +++ b/mod/quiz/tests/behat/settings_form_fields_disableif.feature @@ -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 @@ -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 @@ -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 diff --git a/question/type/ddimageortext/tests/behat/preview.feature b/question/type/ddimageortext/tests/behat/preview.feature index e7966d593818e..2e02529801a2e 100644 --- a/question/type/ddimageortext/tests/behat/preview.feature +++ b/question/type/ddimageortext/tests/behat/preview.feature @@ -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 @@ -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 diff --git a/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php b/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php index b2be3cbfdf84d..364f48bdbadc3 100644 --- a/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php +++ b/question/type/ddmarker/tests/behat/behat_qtype_ddmarker.php @@ -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; diff --git a/question/type/ddmarker/tests/behat/preview.feature b/question/type/ddmarker/tests/behat/preview.feature index 44bf89248119c..dc785357187f6 100644 --- a/question/type/ddmarker/tests/behat/preview.feature +++ b/question/type/ddmarker/tests/behat/preview.feature @@ -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 @@ -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 diff --git a/question/type/ddwtos/tests/behat/preview.feature b/question/type/ddwtos/tests/behat/preview.feature index 24303da4357fc..f0e8424dcf840 100644 --- a/question/type/ddwtos/tests/behat/preview.feature +++ b/question/type/ddwtos/tests/behat/preview.feature @@ -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 diff --git a/repository/tests/behat/behat_filepicker.php b/repository/tests/behat/behat_filepicker.php index 34758fbc1cdd2..c7536317de2be 100644 --- a/repository/tests/behat/behat_filepicker.php +++ b/repository/tests/behat/behat_filepicker.php @@ -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);