diff --git a/admin/tool/behat/tests/behat/manipulate_forms.feature b/admin/tool/behat/tests/behat/manipulate_forms.feature index 126a800f6bb..e04c0d67ee8 100644 --- a/admin/tool/behat/tests/behat/manipulate_forms.feature +++ b/admin/tool/behat/tests/behat/manipulate_forms.feature @@ -7,8 +7,7 @@ Feature: Forms manipulation @javascript Scenario: Basic forms manipulation Given I log in as "admin" - And I follow "Preferences" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode 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" diff --git a/admin/tool/behat/tests/behat/nasty_strings.feature b/admin/tool/behat/tests/behat/nasty_strings.feature index 4b4120d5011..c0605b86698 100644 --- a/admin/tool/behat/tests/behat/nasty_strings.feature +++ b/admin/tool/behat/tests/behat/nasty_strings.feature @@ -10,8 +10,7 @@ Feature: Transform steps arguments | fullname | shortname | category | | Course 1 | C1 | 0 | And I log in as "admin" - And I follow "Preferences" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode Scenario: Use nasty strings on steps arguments When I set the field "Surname" to "$NASTYSTRING1" diff --git a/badges/tests/behat/award_badge.feature b/badges/tests/behat/award_badge.feature index 508fd420c1e..0ce32c02955 100644 --- a/badges/tests/behat/award_badge.feature +++ b/badges/tests/behat/award_badge.feature @@ -31,8 +31,7 @@ Feature: Award badges And I press "Enable access" And I press "Continue" And I click on "Admin User" "link" - And I follow "Profile" in the open menu - And I follow "Edit profile" + And I open my profile in edit mode And I expand all fieldsets And I set the field "Phone" to "123456789" And I press "Update profile" diff --git a/course/tests/behat/navigate_course_list.feature b/course/tests/behat/navigate_course_list.feature index cabeacecbe1..15f003754d7 100644 --- a/course/tests/behat/navigate_course_list.feature +++ b/course/tests/behat/navigate_course_list.feature @@ -33,8 +33,7 @@ Feature: Browse course list and return back from enrolment page @javascript Scenario: A user can return to the previous page from enrolment page by clicking navigation links When I log in as "user2" - And I follow "Preferences" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I expand "Courses" node And I expand "Sample category" node And I follow "Course 1" diff --git a/lib/behat/behat_base.php b/lib/behat/behat_base.php index 3fd7d2b6b39..60b44be6283 100644 --- a/lib/behat/behat_base.php +++ b/lib/behat/behat_base.php @@ -886,4 +886,22 @@ class behat_base extends Behat\MinkExtension\Context\RawMinkContext { // Look for exceptions. $this->look_for_exceptions(); } + + /** + * Get the actual user in the behat session (note $USER does not correspond to the behat session's user). + * @return mixed + * @throws coding_exception + */ + protected function get_session_user() { + global $DB; + $sid = $this->getSession()->getCookie('MoodleSession'); + if (empty($sid)) { + throw new coding_exception('failed to get moodle session'); + } + $userid = $DB->get_field('sessions', 'userid', ['sid' => $sid]); + if (empty($userid)) { + throw new coding_exception('failed to get user from seession id '.$sid); + } + return $DB->get_record('user', ['id' => $userid]); + } } diff --git a/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature b/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature index 478f50e69ad..ffb71fb7462 100644 --- a/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature +++ b/lib/editor/atto/plugins/accessibilitychecker/tests/behat/accessibilitychecker.feature @@ -5,8 +5,7 @@ Feature: Atto accessibility checker @javascript Scenario: Images with no alt Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "
Some plain text
Some more text
" When I click on "Show more buttons" "button" And I click on "Accessibility checker" "button" @@ -31,8 +30,7 @@ Feature: Atto accessibility checker @javascript Scenario: Low contrast Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Hard to read
" When I click on "Show more buttons" "button" And I click on "Accessibility checker" "button" @@ -41,8 +39,7 @@ Feature: Atto accessibility checker @javascript Scenario: No headings Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Sweet roll oat cake jelly-o macaroon donut oat cake. Caramels macaroon cookie sweet roll croissant cheesecake candy jelly-o. Gummies sugar plum sugar plum gingerbread dessert. Tiramisu bonbon jujubes danish marshmallow cookie chocolate cake cupcake tiramisu. Bear claw oat cake chocolate bar croissant. Lollipop cookie topping liquorice croissant. Brownie cookie cupcake lollipop cupcake cupcake. Fruitcake dessert sweet biscuit dragée caramels marzipan brownie. Chupa chups gingerbread apple pie cookie liquorice caramels carrot cake cookie gingerbread. Croissant candy jelly beans. Tiramisu apple pie dessert apple pie macaroon soufflé. Brownie powder carrot cake chocolate. Tart applicake croissant dragée macaroon chocolate donut.
Jelly beans gingerbread tootsie roll. Sugar plum tiramisu cotton candy toffee pie cotton candy tiramisu. Carrot cake chocolate bar sesame snaps cupcake cake dessert sweet fruitcake wafer. Marshmallow cupcake gingerbread pie sweet candy canes powder gummi bears. Jujubes cake muffin marshmallow candy jelly beans tootsie roll pie. Gummi bears applicake chocolate cake sweet jelly sesame snaps lollipop lollipop carrot cake. Marshmallow cake jelly beans. Jelly beans sesame snaps muffin halvah cookie ice cream candy canes carrot cake. Halvah donut marshmallow tiramisu. Cookie dessert gummi bears. Sugar plum apple pie jelly beans gummi bears tart chupa chups. Liquorice macaroon gummi bears gummies macaroon marshmallow sweet roll cake topping. Lemon drops caramels pie icing danish. Chocolate cake oat cake dessert halvah danish carrot cake apple pie.
" When I click on "Show more buttons" "button" And I click on "Accessibility checker" "button" @@ -51,8 +48,7 @@ Feature: Atto accessibility checker @javascript Scenario: Merged cells Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "| Breed | Coolness |
|---|---|
| Poodle | NOT COOL |
| Doberman |
| Breed | Coolness |
|---|---|
| Poodle | NOT COOL |
| Doberman | COOL |
| Breed | Coolness |
|---|---|
| Poodle | NOT COOL |
| Doberman | COOL |
Some plain text
Some plain text
" When I click on "Show more buttons" "button" And I select the text in the "Description" Atto editor diff --git a/lib/editor/atto/plugins/align/tests/behat/align.feature b/lib/editor/atto/plugins/align/tests/behat/align.feature index f3f724add7b..4ed22550c74 100644 --- a/lib/editor/atto/plugins/align/tests/behat/align.feature +++ b/lib/editor/atto/plugins/align/tests/behat/align.feature @@ -5,8 +5,7 @@ Feature: Atto align text @javascript Scenario: Right align some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Fascism
" And I click on "Show more buttons" "button" And I select the text in the "Description" Atto editor @@ -22,8 +21,7 @@ Feature: Atto align text @javascript Scenario: Left align some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Communism
" And I click on "Show more buttons" "button" And I select the text in the "Description" Atto editor @@ -40,8 +38,7 @@ Feature: Atto align text @javascript Scenario: Center align some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "United Future
" And I click on "Show more buttons" "button" And I select the text in the "Description" Atto editor diff --git a/lib/editor/atto/plugins/bold/tests/behat/bold.feature b/lib/editor/atto/plugins/bold/tests/behat/bold.feature index a1d6316a515..7da6988ff13 100644 --- a/lib/editor/atto/plugins/bold/tests/behat/bold.feature +++ b/lib/editor/atto/plugins/bold/tests/behat/bold.feature @@ -5,8 +5,7 @@ Feature: Atto bold button @javascript Scenario: Bold some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Badger" And I select the text in the "Description" Atto editor When I click on "Bold" "button" @@ -21,8 +20,7 @@ Feature: Atto bold button @javascript Scenario: Unbold some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Mouse" And I select the text in the "Description" Atto editor When I click on "Bold" "button" diff --git a/lib/editor/atto/plugins/charmap/tests/behat/charmap.feature b/lib/editor/atto/plugins/charmap/tests/behat/charmap.feature index f7d648169ab..188bbc7dd72 100644 --- a/lib/editor/atto/plugins/charmap/tests/behat/charmap.feature +++ b/lib/editor/atto/plugins/charmap/tests/behat/charmap.feature @@ -5,8 +5,7 @@ Feature: Atto charmap button @javascript Scenario: Insert symbols Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "1980 Mullet
" And I select the text in the "Description" Atto editor When I click on "Show more buttons" "button" diff --git a/lib/editor/atto/plugins/clear/tests/behat/clear.feature b/lib/editor/atto/plugins/clear/tests/behat/clear.feature index 1915c7bffba..16e9d0e49b2 100644 --- a/lib/editor/atto/plugins/clear/tests/behat/clear.feature +++ b/lib/editor/atto/plugins/clear/tests/behat/clear.feature @@ -5,8 +5,7 @@ Feature: Atto clear button @javascript Scenario: Clear formatting Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Pisa" And I select the text in the "Description" Atto editor And I click on "Italic" "button" diff --git a/lib/editor/atto/plugins/collapse/tests/behat/collapse.feature b/lib/editor/atto/plugins/collapse/tests/behat/collapse.feature index 5174ded51b9..dfe8a9231e1 100644 --- a/lib/editor/atto/plugins/collapse/tests/behat/collapse.feature +++ b/lib/editor/atto/plugins/collapse/tests/behat/collapse.feature @@ -5,8 +5,7 @@ Feature: Atto collapse button @javascript Scenario: Toggle toolbar Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode When I click on "Show more buttons" "button" Then "Equation editor" "button" should be visible And I click on "Show fewer buttons" "button" diff --git a/lib/editor/atto/plugins/equation/tests/behat/equation.feature b/lib/editor/atto/plugins/equation/tests/behat/equation.feature index a74efe0bfc6..eaf0d09ecbf 100644 --- a/lib/editor/atto/plugins/equation/tests/behat/equation.feature +++ b/lib/editor/atto/plugins/equation/tests/behat/equation.feature @@ -5,8 +5,7 @@ Feature: Atto equation editor @javascript Scenario: Create an equation Given I log in as "admin" - When I follow "Profile" in the user menu - And I follow "Edit profile" + When I open my profile in edit mode And I set the field "Description" to "Equation test
" # Set field on the bottom of page, so equation editor dialogue is visible. And I expand all fieldsets @@ -24,8 +23,7 @@ Feature: Atto equation editor @javascript Scenario: Edit an equation Given I log in as "admin" - When I follow "Profile" in the user menu - And I follow "Edit profile" + When I open my profile in edit mode And I set the field "Description" to "\( \pi \)
" # Set field on the bottom of page, so equation editor dialogue is visible. And I expand all fieldsets diff --git a/lib/editor/atto/plugins/html/tests/behat/html.feature b/lib/editor/atto/plugins/html/tests/behat/html.feature index cf4613415a5..5cfcc1bbf16 100644 --- a/lib/editor/atto/plugins/html/tests/behat/html.feature +++ b/lib/editor/atto/plugins/html/tests/behat/html.feature @@ -5,8 +5,7 @@ Feature: Atto edit HTML @javascript Scenario: Edit the html source Given I log in as "admin" - When I follow "Profile" in the user menu - And I follow "Edit profile" + When I open my profile in edit mode And I set the field "Description" to "Smurf
" And I click on "Show more buttons" "button" And I click on "HTML" "button" diff --git a/lib/editor/atto/plugins/image/tests/behat/image.feature b/lib/editor/atto/plugins/image/tests/behat/image.feature index 744831de47a..cbbdbef29aa 100644 --- a/lib/editor/atto/plugins/image/tests/behat/image.feature +++ b/lib/editor/atto/plugins/image/tests/behat/image.feature @@ -8,8 +8,7 @@ Feature: Add images to Atto And I follow "Manage private files..." And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager And I click on "Save changes" "button" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode When I set the field "Description" to "Image test
" And I select the text in the "Description" Atto editor And I click on "Image" "button" @@ -52,8 +51,7 @@ Feature: Add images to Atto @javascript Scenario: Manually inserting an image Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Image: .
I need some space.
" And I select the text in the "Description" Atto editor And I click on "Show more buttons" "button" @@ -22,8 +21,7 @@ Feature: Indent text in Atto @javascript Scenario: Indent and outdent Given I log in as "admin" - And I follow "Profile" in the user menu - When I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "I need some space.
" And I select the text in the "Description" Atto editor And I click on "Show more buttons" "button" diff --git a/lib/editor/atto/plugins/italic/tests/behat/italic.feature b/lib/editor/atto/plugins/italic/tests/behat/italic.feature index cd063f069e7..d2fcae15757 100644 --- a/lib/editor/atto/plugins/italic/tests/behat/italic.feature +++ b/lib/editor/atto/plugins/italic/tests/behat/italic.feature @@ -5,8 +5,7 @@ Feature: Atto italic button @javascript Scenario: Italicise some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Tower of Pisa" And I select the text in the "Description" Atto editor When I click on "Italic" "button" @@ -21,8 +20,7 @@ Feature: Atto italic button @javascript Scenario: Toggle italics in some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "GHD - for hair" And I select the text in the "Description" Atto editor When I click on "Italic" "button" diff --git a/lib/editor/atto/plugins/link/tests/behat/link.feature b/lib/editor/atto/plugins/link/tests/behat/link.feature index 0a0234adaea..93c028d17cc 100644 --- a/lib/editor/atto/plugins/link/tests/behat/link.feature +++ b/lib/editor/atto/plugins/link/tests/behat/link.feature @@ -8,8 +8,7 @@ Feature: Add links to Atto And I follow "Manage private files..." And I upload "lib/editor/atto/tests/fixtures/moodle-logo.png" file to "Files" filemanager And I click on "Save changes" "button" - When I follow "Profile" in the user menu - And I follow "Edit profile" + When I open my profile in edit mode And I set the field "Description" to "Super cool" And I select the text in the "Description" Atto editor And I click on "Link" "button" diff --git a/lib/editor/atto/plugins/orderedlist/tests/behat/orderedlist.feature b/lib/editor/atto/plugins/orderedlist/tests/behat/orderedlist.feature index 6c0dbd2b1ab..dc94ca758a7 100644 --- a/lib/editor/atto/plugins/orderedlist/tests/behat/orderedlist.feature +++ b/lib/editor/atto/plugins/orderedlist/tests/behat/orderedlist.feature @@ -5,8 +5,7 @@ Feature: Atto ordered list button @javascript Scenario: Make a list from some text Given I log in as "admin" - And I follow "Profile" in the user menu - And I follow "Edit profile" + And I open my profile in edit mode And I set the field "Description" to "Have you heard the news everyone's talking