From a157baa65a5268e4e6100811ace5bb7302436618 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Thu, 15 Aug 2019 08:47:17 +0800 Subject: [PATCH] MDL-66378 behat: Correct invalid uses of selection from dropdown --- .../history/tests/behat/basic_functionality.feature | 4 ++-- .../report/singleview/tests/behat/singleview.feature | 2 +- .../tinymce/tests/behat/disablecontrol.feature | 4 ++-- mod/glossary/tests/behat/categories.feature | 4 ++-- user/tests/behat/behat_user.php | 12 ++++-------- 5 files changed, 11 insertions(+), 15 deletions(-) diff --git a/grade/report/history/tests/behat/basic_functionality.feature b/grade/report/history/tests/behat/basic_functionality.feature index 119bd083f92..89993bc3dd8 100644 --- a/grade/report/history/tests/behat/basic_functionality.feature +++ b/grade/report/history/tests/behat/basic_functionality.feature @@ -77,7 +77,7 @@ Feature: A teacher checks the grade history report in a course | Student 2 | The greatest assignment ever | 50.00 | 70.00 | Teacher 2 | | Student 2 | Rewarding assignment | 60.00 | 80.00 | Teacher 2 | # Test filtering by assignment. - And I click on "The greatest assignment ever" "option" in the "#id_itemid" "css_element" + And I set the field "Grade item" to "The greatest assignment ever" And I press "Submit" And the following should exist in the "gradereport_history" table: | First name/Surname | Grade item | Original grade | Revised grade | Grader | @@ -87,7 +87,7 @@ Feature: A teacher checks the grade history report in a course | Student 1 | Rewarding assignment | | 60.00 | Teacher 1 | | Student 1 | Rewarding assignment | 60.00 | 80.00 | Teacher 2 | # Test filtering by grader. - And I click on "Teacher 1" "option" in the "#id_grader" "css_element" + And I set the field "Grader" to "Teacher 1" And I press "Submit" And the following should exist in the "gradereport_history" table: | First name/Surname | Grade item | Original grade | Revised grade | Grader | diff --git a/grade/report/singleview/tests/behat/singleview.feature b/grade/report/singleview/tests/behat/singleview.feature index e6a2dbc8103..e18eb5c46eb 100644 --- a/grade/report/singleview/tests/behat/singleview.feature +++ b/grade/report/singleview/tests/behat/singleview.feature @@ -98,7 +98,7 @@ Feature: We can use Single view And I log in as "teacher2" And I am on "Course 1" course homepage Given I navigate to "View > Single view" in the course gradebook - And I click on "Student 4" "option" + And I select "Student 4" from the "Select user..." singleselect And the "Exclude for Test assignment one" "checkbox" should be disabled And the "Override for Test assignment one" "checkbox" should be enabled diff --git a/lib/editor/tinymce/tests/behat/disablecontrol.feature b/lib/editor/tinymce/tests/behat/disablecontrol.feature index d8cc6da908d..084738321b9 100644 --- a/lib/editor/tinymce/tests/behat/disablecontrol.feature +++ b/lib/editor/tinymce/tests/behat/disablecontrol.feature @@ -22,7 +22,7 @@ Feature: Tinymce with enable/disable function. @javascript Scenario: Check disable Tinymce editor. - When I click on "option[value=1]" "css_element" in the "select#id_mycontrol" "css_element" + When I set the field "My control" to "Disable" Then the "class" attribute of "a#id_myeditor_pdw_toggle" "css_element" should contain "mceButtonDisabled" And the "class" attribute of "table#id_myeditor_formatselect" "css_element" should contain "mceListBoxDisabled" And the "class" attribute of "a#id_myeditor_bold" "css_element" should contain "mceButtonDisabled" @@ -39,7 +39,7 @@ Feature: Tinymce with enable/disable function. @javascript Scenario: Check enable Tinymce editor. - When I click on "option[value=0]" "css_element" in the "select#id_mycontrol" "css_element" + When I set the field "My control" to "Enable" Then the "class" attribute of "a#id_myeditor_pdw_toggle" "css_element" should contain "mceButtonEnabled" And the "class" attribute of "table#id_myeditor_formatselect" "css_element" should contain "mceListBoxEnabled" And the "class" attribute of "a#id_myeditor_bold" "css_element" should contain "mceButtonEnabled" diff --git a/mod/glossary/tests/behat/categories.feature b/mod/glossary/tests/behat/categories.feature index 193488dbc02..53597c47282 100644 --- a/mod/glossary/tests/behat/categories.feature +++ b/mod/glossary/tests/behat/categories.feature @@ -85,7 +85,7 @@ Feature: Glossary entries can be organised in categories And "//h4[contains(.,'EntryCategoryNL')]" "xpath_element" should appear after "//h3[contains(.,'CATEGORYNOLINKS')]" "xpath_element" And I should not see "EntryNoCategory" And I set the field "hook" to "Not categorised" - And I click on "Not categorised" "option" in the "#catmenu select" "css_element" + And I set the field "Categories" to "Not categorised" And I should see "EntryNoCategory" And I should not see "EntryCategoryNL" And I should not see "EntryCategoryAL" @@ -112,7 +112,7 @@ Feature: Glossary entries can be organised in categories And I should not see "EntryNoCategory" And I should not see "EntryCategoryAL" And I should see "EntryCategoryBoth" - And I click on "Not categorised" "option" in the "#catmenu select" "css_element" + And I set the field "Categories" to "Not categorised" And I should see "EntryNoCategory" And I should see "EntryCategoryAL" And I should not see "EntryCategoryBoth" diff --git a/user/tests/behat/behat_user.php b/user/tests/behat/behat_user.php index a3f4bbaf27b..eff2a766406 100644 --- a/user/tests/behat/behat_user.php +++ b/user/tests/behat/behat_user.php @@ -46,14 +46,10 @@ class behat_user extends behat_base { * @param string $nodetext The menu item to select. */ public function i_choose_from_the_participants_page_bulk_action_menu($nodetext) { - $nodetext = behat_context_helper::escape($nodetext); - - // Open the select. - $this->execute("behat_general::i_click_on", array("//select[@id='formactionid']", "xpath_element")); - - // Click on the option. - $this->execute("behat_general::i_click_on", array("//select[@id='formactionid']" . - "/option[contains(., " . $nodetext . ")]", "xpath_element")); + $this->execute("behat_forms::i_set_the_field_to", [ + "With selected users...", + $this->escape($nodetext) + ]); } /**