diff --git a/blocks/site_main_menu/tests/behat/behat_block_site_main_menu.php b/blocks/site_main_menu/tests/behat/behat_block_site_main_menu.php index b80713c60c69e..f99f479b5d9e8 100644 --- a/blocks/site_main_menu/tests/behat/behat_block_site_main_menu.php +++ b/blocks/site_main_menu/tests/behat/behat_block_site_main_menu.php @@ -150,4 +150,17 @@ public function i_open_actions_menu_in_site_main_menu_block($activityname) { $xpath = "//*[contains(concat(' ',normalize-space(@class),' '),' block_site_main_menu ')]//li[contains(., $activityname)]"; $this->execute('behat_action_menu::i_open_the_action_menu_in', [$xpath, 'xpath_element']); } + + /** + * Return the list of partial named selectors. + * + * @return array + */ + public static function get_partial_named_selectors(): array { + return [ + new behat_component_named_selector('Activity', [ + "//*[contains(concat(' ',normalize-space(@class),' '),' block_site_main_menu ')]//li[contains(., %locator%)]" + ]), + ]; + } } diff --git a/blocks/site_main_menu/tests/behat/edit_activities.feature b/blocks/site_main_menu/tests/behat/edit_activities.feature index 0f6d8c28e3730..51b60ea550064 100644 --- a/blocks/site_main_menu/tests/behat/edit_activities.feature +++ b/blocks/site_main_menu/tests/behat/edit_activities.feature @@ -6,15 +6,16 @@ Feature: Edit activities in main menu block @javascript Scenario: Edit name of acitivity in-place in site main menu block - Given I log in as "admin" + Given the following "activity" exists: + | activity | forum | + | course | Acceptance test site | + | name | My forum name | + | idnumber | forum | + And I log in as "admin" And I am on site homepage And I navigate to "Turn editing on" in current page administration And I add the "Main menu" block - When I add a "Forum" to section "0" and I fill the form with: - | Forum name | My forum name | - And I click on "Edit title" "link" in the "My forum name" activity in site main menu block - And I set the field "New name for activity My forum name" to "New forum name" - And I press the enter key + When I set the field "Edit title" in the "My forum name" "block_site_main_menu > Activity" to "New forum name" Then I should not see "My forum name" And I should see "New forum name" And I follow "New forum name" diff --git a/blocks/social_activities/tests/behat/behat_block_social_activities.php b/blocks/social_activities/tests/behat/behat_block_social_activities.php index 167b24d51a2c0..eb285231f83e2 100644 --- a/blocks/social_activities/tests/behat/behat_block_social_activities.php +++ b/blocks/social_activities/tests/behat/behat_block_social_activities.php @@ -158,4 +158,17 @@ public function i_open_actions_menu_in_social_activities_block($activityname) { $xpath = "//*[contains(concat(' ',normalize-space(@class),' '),' block_social_activities ')]//li[contains(., $activityname)]"; $this->execute('behat_action_menu::i_open_the_action_menu_in', [$xpath, 'xpath_element']); } + + /** + * Return the list of partial named selectors. + * + * @return array + */ + public static function get_partial_named_selectors(): array { + return [ + new behat_component_named_selector('Activity', [ + "//*[contains(concat(' ',normalize-space(@class),' '),' block_social_activities ')]//li[contains(., %locator%)]", + ]), + ]; + } } diff --git a/blocks/social_activities/tests/behat/edit_activities.feature b/blocks/social_activities/tests/behat/edit_activities.feature index 984b73173a3c8..a21e848de7115 100644 --- a/blocks/social_activities/tests/behat/edit_activities.feature +++ b/blocks/social_activities/tests/behat/edit_activities.feature @@ -25,9 +25,7 @@ Feature: Edit activities in social activities block And I click on "Add a new Forum" "link" in the "Add an activity or resource" "dialogue" And I set the field "Forum name" to "My forum name" And I press "Save and return to course" - And I click on "Edit title" "link" in the "My forum name" activity in social activities block - And I set the field "New name for activity My forum name" to "New forum name" - And I press the enter key + When I set the field "Edit title" in the "My forum name" "block_social_activities > Activity" to "New forum name" Then I should not see "My forum name" in the "Social activities" "block" And I should see "New forum name" And I follow "New forum name" @@ -84,4 +82,3 @@ Feature: Edit activities in social activities block And I should not see "My forum name" in the "Social activities" "block" And I click on "My forum name" "link" in the "Recent activity" "block" And I should see "My forum name" in the ".breadcrumb" "css_element" - And I log out diff --git a/cohort/tests/behat/add_cohort.feature b/cohort/tests/behat/add_cohort.feature index 9bc546951faad..c422c70f6625c 100644 --- a/cohort/tests/behat/add_cohort.feature +++ b/cohort/tests/behat/add_cohort.feature @@ -62,9 +62,7 @@ Feature: Add cohorts of users @javascript Scenario: Edit cohort name in-place When I follow "Cohorts" - And I click on "Edit cohort name" "link" in the "Test cohort name" "table_row" - And I set the field "New name for cohort Test cohort name" to "Students cohort" - And I press the enter key + And I set the field "Edit cohort name" to "Students cohort" Then I should not see "Test cohort name" And I should see "Students cohort" And I follow "Cohorts" diff --git a/course/format/topics/tests/behat/edit_delete_sections.feature b/course/format/topics/tests/behat/edit_delete_sections.feature index a1e205b3c1931..573c7e50fcd02 100644 --- a/course/format/topics/tests/behat/edit_delete_sections.feature +++ b/course/format/topics/tests/behat/edit_delete_sections.feature @@ -53,9 +53,7 @@ Feature: Sections can be edited and deleted in topics format @javascript Scenario: Inline edit section name in topics format - When I click on "Edit topic name" "link" in the "li#section-1" "css_element" - And I set the field "New name for topic Topic 1" to "Midterm evaluation" - And I press the enter key + When I set the field "Edit topic name" in the "li#section-1" "css_element" to "Midterm evaluation" Then I should not see "Topic 1" in the "region-main" "region" And "New name for topic" "field" should not exist And I should see "Midterm evaluation" in the "li#section-1" "css_element" diff --git a/course/format/weeks/tests/behat/edit_delete_sections.feature b/course/format/weeks/tests/behat/edit_delete_sections.feature index 5d8ff891130f1..6fdc14aef2636 100644 --- a/course/format/weeks/tests/behat/edit_delete_sections.feature +++ b/course/format/weeks/tests/behat/edit_delete_sections.feature @@ -54,9 +54,7 @@ Feature: Sections can be edited and deleted in weeks format @javascript Scenario: Inline edit section name in weeks format - When I click on "Edit week name" "link" in the "li#section-1" "css_element" - And I set the field "New name for week 1 May - 7 May" to "Midterm evaluation" - And I press the enter key + When I set the field "Edit week name" in the "li#section-1" "css_element" to "Midterm evaluation" Then I should not see "1 May - 7 May" in the "region-main" "region" And "New name for week" "field" should not exist And I should see "Midterm evaluation" in the "li#section-1" "css_element" diff --git a/course/tests/behat/activities_edit_name.feature b/course/tests/behat/activities_edit_name.feature index 7372c1741a1e0..18217384e980f 100644 --- a/course/tests/behat/activities_edit_name.feature +++ b/course/tests/behat/activities_edit_name.feature @@ -15,15 +15,16 @@ Feature: Edit activity name in-place And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | + And the following "activity" exists: + | course | C1 | + | activity | forum | + | name | Test forum name | + | description | Test forum description | + | idnumber | forum1 | When I log in as "teacher1" And I am on "Course 1" course homepage with editing mode on - And I add a "Forum" to section "1" and I fill the form with: - | Forum name | Test forum name | - | Description | Test forum description | # Rename activity - And I click on "Edit title" "link" in the "//div[contains(@class,'activityinstance') and contains(.,'Test forum name')]" "xpath_element" - And I set the field "New name for activity Test forum name" to "Good news" - And I press the enter key + And I set the field "Edit title" in the "Test forum name" "activity" to "Good news" Then I should not see "Test forum name" in the ".course-content" "css_element" And "New name for activity Test forum name" "field" should not exist And I should see "Good news" @@ -32,7 +33,7 @@ Feature: Edit activity name in-place And I should not see "Test forum name" # Cancel renaming And I click on "Edit title" "link" in the "//div[contains(@class,'activityinstance') and contains(.,'Good news')]" "xpath_element" - And I set the field "New name for activity Good news" to "Terrible news" + And I type "Terrible news" And I press the escape key And "New name for activity Good news" "field" should not exist And I should see "Good news" diff --git a/course/tests/behat/behat_course.php b/course/tests/behat/behat_course.php index 26cecd130b7ae..d06a8bf6c0d85 100644 --- a/course/tests/behat/behat_course.php +++ b/course/tests/behat/behat_course.php @@ -852,22 +852,12 @@ public function i_move_activity_to_section($activityname, $sectionnumber) { * @param string $newactivityname */ public function i_change_activity_name_to($activityname, $newactivityname) { - - if (!$this->running_javascript()) { - throw new DriverException('Change activity name step is not available with Javascript disabled'); - } - - $activity = $this->escape($activityname); - - $this->execute('behat_course::i_click_on_in_the_activity', - array(get_string('edittitle'), "link", $activity) - ); - - // Adding chr(10) to save changes. - $this->execute('behat_forms::i_set_the_field_to', - array('title', $this->escape($newactivityname) . chr(10)) - ); - + $this->execute('behat_forms::i_set_the_field_in_container_to', [ + get_string('edittitle'), + $activityname, + 'activity', + $newactivityname + ]); } /** diff --git a/customfield/tests/behat/edit_categories.feature b/customfield/tests/behat/edit_categories.feature index 2b88046c08803..b44a66163fcea 100644 --- a/customfield/tests/behat/edit_categories.feature +++ b/customfield/tests/behat/edit_categories.feature @@ -12,7 +12,6 @@ Feature: Managers can manage categories for course custom fields Then I should see "Other fields" in the "#customfield_catlist" "css_element" And I navigate to "Reports > Logs" in site administration And I press "Get these logs" - And I log out Scenario: Edit a category name for custom course fields Given the following "custom field categories" exist: @@ -20,15 +19,12 @@ Feature: Managers can manage categories for course custom fields | Category for test | core_course | course | 0 | And I log in as "admin" And I navigate to "Courses > Course custom fields" in site administration - And I click on "Edit category name" "link" in the "//div[contains(@class,'categoryinstance') and contains(.,'Category for test')]" "xpath_element" - And I set the field "New value for Category for test" to "Good fields" - And I press the enter key + And I set the field "Edit category name" in the "//div[contains(@class,'categoryinstance') and contains(.,'Category for test')]" "xpath_element" to "Good fields" Then I should not see "Category for test" in the "#customfield_catlist" "css_element" And "New value for Category for test" "field" should not exist And I should see "Good fields" in the "#customfield_catlist" "css_element" And I navigate to "Reports > Logs" in site administration And I press "Get these logs" - And I log out Scenario: Delete a category for custom course fields Given the following "custom field categories" exist: @@ -46,7 +42,6 @@ Feature: Managers can manage categories for course custom fields Then I should not see "Test category" in the "#customfield_catlist" "css_element" And I navigate to "Reports > Logs" in site administration And I press "Get these logs" - And I log out Scenario: Move field in the course custom fields to another category Given the following "custom field categories" exist: @@ -78,7 +73,6 @@ Feature: Managers can manage categories for course custom fields And I press "Move \"Field1\"" And I follow "After field Field2" And "Field1" "text" should appear after "Field2" "text" - And I log out Scenario: Reorder course custom field categories Given the following "custom field categories" exist: @@ -108,4 +102,3 @@ Feature: Managers can manage categories for course custom fields And "Field1" "text" should appear after "Category1" "text" And "Category2" "text" should appear after "Field1" "text" And "Category3" "text" should appear after "Category2" "text" - And I log out diff --git a/mod/book/tests/behat/edit_tags.feature b/mod/book/tests/behat/edit_tags.feature index 938b07f9a2da1..7b2b8c70e60cc 100644 --- a/mod/book/tests/behat/edit_tags.feature +++ b/mod/book/tests/behat/edit_tags.feature @@ -12,16 +12,16 @@ Feature: Edited book chapters handle tags correctly And the following "courses" exist: | fullname | shortname | format | | Course 1 | C1 | topics | + And the following "activity" exists: + | activity | book | + | course | C1 | + | idnumber | book1 | + | name | Test book | + | description | A book about dreams | And the following "course enrolments" exist: | user | course | role | | teacher1 | C1 | editingteacher | | student1 | C1 | student | - And I log in as "teacher1" - And I am on "Course 1" course homepage with editing mode on - And I add a "Book" to section "1" and I fill the form with: - | Name | Test book | - | Description | A book about dreams! | - And I log out Scenario: Book chapter edition of custom tags works as expected Given I log in as "teacher1" diff --git a/mod/forum/tests/behat/advanced_search.feature b/mod/forum/tests/behat/advanced_search.feature index 90dd16298c83b..dbcca3b8797fd 100644 --- a/mod/forum/tests/behat/advanced_search.feature +++ b/mod/forum/tests/behat/advanced_search.feature @@ -130,8 +130,7 @@ Feature: The forum search allows users to perform advanced searches for forum po And I press "Search forums" And I should see "Advanced search" And I set the field "Is tagged with" to "SearchedTag" - And I click on "[data-value='SearchedTag']" "css_element" - And I press the escape key + And I press the enter key When I press "Search forums" Then I should see "My subject" And I should not see "Your subjective" diff --git a/mod/lti/tests/behat/renametool.feature b/mod/lti/tests/behat/renametool.feature index 30eed0702d0b8..48eee71af4c1d 100644 --- a/mod/lti/tests/behat/renametool.feature +++ b/mod/lti/tests/behat/renametool.feature @@ -21,9 +21,7 @@ Feature: Rename external tools via inline editing And I am on "Course 1" course homepage with editing mode on And I add a "External tool" to section "1" and I fill the form with: | Activity name | Test tool activity 1 | - And I click on "Edit title" "link" in the "li#section-1" "css_element" - And I set the field "New name for activity Test tool activity 1" to "Test tool activity renamed" - And I press the enter key + And I set the field "Edit title" in the "li#section-1" "css_element" to "Test tool activity renamed" And I navigate to "Setup > Gradebook setup" in the course gradebook Then I should not see "Test tool activity 1" And I should see "Test tool activity renamed" diff --git a/mod/quiz/tests/behat/behat_mod_quiz.php b/mod/quiz/tests/behat/behat_mod_quiz.php index 5db5ba702e709..417b26d370a0b 100644 --- a/mod/quiz/tests/behat/behat_mod_quiz.php +++ b/mod/quiz/tests/behat/behat_mod_quiz.php @@ -397,7 +397,8 @@ public function i_set_the_max_mark_for_quiz_question($questionname, $newmark) { $this->execute('behat_general::assert_page_contains_text', $this->escape(get_string('edittitleinstructions'))); - $this->execute('behat_forms::i_set_the_field_to', array('maxmark', $this->escape($newmark) . chr(10))); + $this->execute('behat_general::i_type', [$newmark]); + $this->execute('behat_general::i_press_named_key', ['', 'enter']); } /** @@ -653,7 +654,9 @@ public function i_set_the_section_heading_for($sectionname, $sectionheading) { $this->execute('behat_general::assert_page_contains_text', $this->escape(get_string('edittitleinstructions'))); - $this->execute('behat_forms::i_set_the_field_to', array('section', $this->escape($sectionheading) . chr(10))); + $this->execute('behat_general::i_press_named_key', ['', 'backspace']); + $this->execute('behat_general::i_type', [$sectionheading]); + $this->execute('behat_general::i_press_named_key', ['', 'enter']); } /** diff --git a/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature b/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature index b4bee513a0bdb..47a382f176279 100644 --- a/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature +++ b/mod/quiz/tests/behat/editing_set_marks_no_attempts.feature @@ -17,16 +17,19 @@ Feature: Edit quiz marks with no attempts And the following "activities" exist: | activity | name | course | idnumber | grade | decimalpoints | questiondecimalpoints | | quiz | Quiz 1 | C1 | quiz1 | 20 | 2 | -1 | - And I log in as "teacher1" - And I am on "Course 1" course homepage - And I add a "True/False" question to the "Quiz 1" quiz with: - | Question name | First question | - | Question text | Answer me | - | Default mark | 2.0 | - And I add a "True/False" question to the "Quiz 1" quiz with: - | Question name | Second question | - | Question text | Answer again | - | Default mark | 3.0 | + + And the following "question categories" exist: + | contextlevel | reference | name | + | Course | C1 | Test questions | + And the following "questions" exist: + | questioncategory | qtype | name | questiontext | + | Test questions | truefalse | First question | Answer me | + | Test questions | truefalse | Second question | Answer again | + And quiz "Quiz 1" contains the following questions: + | question | page | maxmark | + | First question | 1 | 2.0 | + | Second question | 1 | 3.0 | + And I am on the "Quiz 1" "mod_quiz > Edit" page logged in as "teacher1" @javascript Scenario: Set the max mark for a question. diff --git a/tag/tests/behat/collections.feature b/tag/tests/behat/collections.feature index 6cdb568b7c4e2..50bdd8bf9cbf9 100644 --- a/tag/tests/behat/collections.feature +++ b/tag/tests/behat/collections.feature @@ -28,15 +28,11 @@ Feature: Managers can create and manage tag collections Scenario: Adding tag collections When I follow "Hobbies" Then I should see "Nothing to display" - And I log out Scenario: Editing tag collections - When I click on "Edit tag collection name" "link" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Hobbies')]" "xpath_element" - And I set the field "New name for tag collection Hobbies" to "Newname" - And I press the enter key + When I set the field "Edit tag collection name" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Hobbies')]" "xpath_element" to "Newname" Then I should not see "Hobbies" And I should see "Newname" - And I log out Scenario: Resorting tag collections When I follow "Add tag collection" @@ -48,41 +44,34 @@ Feature: Managers can create and manage tag collections And "Blogging" "link" should appear before "Hobbies" "link" And I click on "Move down" "link" in the "Blogging" "table_row" And "Blogging" "link" should appear after "Hobbies" "link" - And I log out Scenario: Deleting tag collections When I click on "Delete" "link" in the "Hobbies" "table_row" Then I should see "Are you sure you want to delete tag collection \"Hobbies\"?" And I press "Yes" And I should not see "Hobbies" - And I log out Scenario: Assigning tag area to tag collection And I should see "User interests" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Default collection')]" "xpath_element" And I should not see "User interests" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Hobbies')]" "xpath_element" - When I click on "Change tag collection" "link" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" - And I set the field "Change tag collection of area User interests" to "Hobbies" + When I set the field "Change tag collection" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" to "Hobbies" Then I should not see "User interests" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Default collection')]" "xpath_element" And I should see "User interests" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Hobbies')]" "xpath_element" And I should see "Hobbies" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" - And I log out Scenario: Disabling tag areas When I click on "Disable" "link" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" And I should not see "User interests" in the "table.tag-collections-table" "css_element" And I click on "Enable" "link" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" And I should see "User interests" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Default collection')]" "xpath_element" - And I log out Scenario: Deleting non-empty tag collections - When I click on "Change tag collection" "link" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" - And I set the field "Change tag collection of area User interests" to "Hobbies" + When I set the field "Change tag collection" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" to "Hobbies" And I click on "Delete" "link" in the "Hobbies" "table_row" Then I should see "Are you sure you want to delete tag collection \"Hobbies\"?" And I press "Yes" And I should not see "Hobbies" And I should see "User interests" in the "//table[contains(@class,'tag-collections-table')]//tr[contains(.,'Default collection')]" "xpath_element" - And I log out Scenario: Moving tags when changing tag collections And I open my profile in edit mode @@ -90,8 +79,7 @@ Feature: Managers can create and manage tag collections And I set the field "List of interests" to "Swimming, Tag0, Tag3" And I press "Update profile" And I navigate to "Appearance > Manage tags" in site administration - When I click on "Change tag collection" "link" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" - And I set the field "Change tag collection of area User interests" to "Hobbies" + When I set the field "Change tag collection" in the "//table[contains(@class,'tag-areas-table')]//tr[contains(.,'User interests')]" "xpath_element" to "Hobbies" And I follow "Hobbies" Then I should see "Swimming" And I should see "Tag0" @@ -107,7 +95,6 @@ Feature: Managers can create and manage tag collections And I should see "Tag3" And I should see "Tag1" And I should see "Tag2" - And I log out Scenario: Creating searchable and non-searchable tag collections And I follow "Add tag collection" @@ -129,4 +116,3 @@ Feature: Managers can create and manage tag collections And I click on "Site pages" "list_item" in the "Navigation" "block" And I click on "Tags" "link" in the "Navigation" "block" And "Select tag collection" "select" should not exist - And I log out diff --git a/tag/tests/behat/edit_tag.feature b/tag/tests/behat/edit_tag.feature index 4682edb587bbb..c3bc35e51ec9a 100644 --- a/tag/tests/behat/edit_tag.feature +++ b/tag/tests/behat/edit_tag.feature @@ -158,19 +158,14 @@ Feature: Users can edit tags to add description or rename And I navigate to "Appearance > Manage tags" in site administration And I follow "Default collection" # Renaming tag to a valid name - And I click on "Edit tag name" "link" in the "Cat" "table_row" - And I set the field "New name for tag Cat" to "Kitten" - And I press the enter key + And I set the field "Edit tag name" in the "Cat" "table_row" to "Kitten" Then I should not see "Cat" And "New name for tag" "field" should not exist - And I wait until "Kitten" "link" exists And I follow "Default collection" And I should see "Kitten" And I should not see "Cat" # Renaming tag to an invalid name - And I click on "Edit tag name" "link" in the "Turtle" "table_row" - And I set the field "New name for tag Turtle" to "DOG" - And I press the enter key + And I set the field "Edit tag name" in the "Turtle" "table_row" to "DOG" And I should see "The tag name is already in use. Do you want to combine these tags?" And I click on "Cancel" "button" in the "Confirm" "dialogue" And "New name for tag" "field" should not exist @@ -183,7 +178,7 @@ Feature: Users can edit tags to add description or rename And I should not see "DOG" # Cancel tag renaming And I click on "Edit tag name" "link" in the "Dog" "table_row" - And I set the field "New name for tag Dog" to "Penguin" + And I type "Penguin" And I press the escape key And "New name for tag" "field" should not exist And I should see "Turtle" @@ -197,9 +192,7 @@ Feature: Users can edit tags to add description or rename When I log in as "manager1" And I navigate to "Appearance > Manage tags" in site administration And I follow "Default collection" - And I click on "Edit tag name" "link" in the "Turtle" "table_row" - And I set the field "New name for tag Turtle" to "DOG" - And I press the enter key + And I set the field "Edit tag name" in the "Turtle" "table_row" to "DOG" And I should see "The tag name is already in use. Do you want to combine these tags?" And I press "Yes" Then I should not see "Turtle"