$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%)]"
+ ]),
+ ];
+ }
}
@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"
$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%)]",
+ ]),
+ ];
+ }
}
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"
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
@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"
@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"
@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"
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"
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"
* @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
+ ]);
}
/**
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:
| 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:
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:
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:
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
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"
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"
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"
$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']);
}
/**
$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']);
}
/**
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.
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"
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
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"
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"
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
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
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"
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"