diff --git a/auth/email/tests/behat/behat_auth_email.php b/auth/email/tests/behat/behat_auth_email.php index b3fe2fbbca165..83924f7029b98 100644 --- a/auth/email/tests/behat/behat_auth_email.php +++ b/auth/email/tests/behat/behat_auth_email.php @@ -49,6 +49,6 @@ public function i_confirm_email_for($username) { $confirmationpath = $confirmationurl->out_as_local_url(false); $url = $confirmationpath . '?' . 'data='. $secret .'/'. $username; - $this->getSession()->visit($this->locate_path($url)); + $this->execute('behat_general::i_visit', [$url]); } } diff --git a/auth/tests/behat/behat_auth.php b/auth/tests/behat/behat_auth.php index e7b65e581ff37..6233454f99f2b 100644 --- a/auth/tests/behat/behat_auth.php +++ b/auth/tests/behat/behat_auth.php @@ -58,7 +58,7 @@ public function i_log_in_as(string $username, moodle_url $wantsurl = null) { } // Visit login page. - $this->getSession()->visit($this->locate_path($loginurl->out_as_local_url())); + $this->execute('behat_general::i_visit', [$loginurl]); // Enter username and password. $this->execute('behat_forms::i_set_the_field_to', array('Username', $this->escape($username))); diff --git a/backup/util/ui/tests/behat/behat_backup.php b/backup/util/ui/tests/behat/behat_backup.php index a5ead37837042..fe5f57544beb0 100644 --- a/backup/util/ui/tests/behat/behat_backup.php +++ b/backup/util/ui/tests/behat/behat_backup.php @@ -56,7 +56,7 @@ public function i_backup_course_using_this_options($backupcourse, $options = fal // table elements are used, and we need to catch exceptions contantly. // Go to homepage. - $this->getSession()->visit($this->locate_path('/?redirect=0')); + $this->execute('behat_general::i_visit', ['/?redirect=0']); $this->execute("behat_general::wait_until_the_page_is_ready"); // Click the course link. @@ -98,7 +98,7 @@ public function i_perform_a_quick_backup_of_course($backupcourse) { // table elements are used, and we need to catch exceptions contantly. // Go to homepage. - $this->getSession()->visit($this->locate_path('/?redirect=0')); + $this->execute('behat_general::i_visit', ['/?redirect=0']); // Click the course link. $this->execute("behat_general::click_link", $backupcourse); @@ -134,7 +134,7 @@ public function i_import_course_into_course($fromcourse, $tocourse, $options = f // table elements are used, and we need to catch exceptions contantly. // Go to homepage. - $this->getSession()->visit($this->locate_path('/?redirect=0')); + $this->execute('behat_general::i_visit', ['/?redirect=0']); $this->execute("behat_general::wait_until_the_page_is_ready"); // Click the course link. diff --git a/calendar/tests/behat/behat_calendar.php b/calendar/tests/behat/behat_calendar.php index 1c6cb4ccb3066..e089afc01a34c 100644 --- a/calendar/tests/behat/behat_calendar.php +++ b/calendar/tests/behat/behat_calendar.php @@ -121,7 +121,7 @@ public function i_hover_over_today_in_the_calendar() { */ public function i_view_the_calendar_for($month, $year) { $time = make_timestamp($year, $month, 1); - $this->getSession()->visit($this->locate_path('/calendar/view.php?view=month&course=1&time='.$time)); + $this->execute('behat_general::i_visit', ['/calendar/view.php?view=month&course=1&time='.$time]); } @@ -134,6 +134,6 @@ public function i_view_the_calendar_for($month, $year) { */ public function i_am_viewing_site_calendar() { $url = new moodle_url('/calendar/view.php', ['view' => 'month']); - $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + $this->execute('behat_general::i_visit', [$url]); } } diff --git a/lib/tests/behat/behat_app.php b/lib/tests/behat/behat_app.php index e474ffc67371a..ce9f392c01d09 100644 --- a/lib/tests/behat/behat_app.php +++ b/lib/tests/behat/behat_app.php @@ -283,7 +283,7 @@ protected function prepare_browser(string $url) { global $CFG; // Visit the Ionic URL and wait for it to load. - $this->getSession()->visit($url); + $this->execute('behat_general::i_visit', [$url]); $this->spin( function($context, $args) { $title = $context->getSession()->getPage()->find('xpath', '//title'); diff --git a/lib/tests/behat/behat_general.php b/lib/tests/behat/behat_general.php index e8976d756a2b1..49b2fdd63c0f3 100644 --- a/lib/tests/behat/behat_general.php +++ b/lib/tests/behat/behat_general.php @@ -74,7 +74,7 @@ class behat_general extends behat_base { * @Given /^I am on homepage$/ */ public function i_am_on_homepage() { - $this->getSession()->visit($this->locate_path('/')); + $this->execute('behat_general::i_visit', ['/']); } /** @@ -83,7 +83,7 @@ public function i_am_on_homepage() { * @Given /^I am on site homepage$/ */ public function i_am_on_site_homepage() { - $this->getSession()->visit($this->locate_path('/?redirect=0')); + $this->execute('behat_general::i_visit', ['/?redirect=0']); } /** @@ -92,7 +92,7 @@ public function i_am_on_site_homepage() { * @Given /^I am on course index$/ */ public function i_am_on_course_index() { - $this->getSession()->visit($this->locate_path('/course/index.php')); + $this->execute('behat_general::i_visit', ['/course/index.php']); } /** @@ -1057,7 +1057,7 @@ public function should_not_exist($element, $selectortype) { * @Given /^I trigger cron$/ */ public function i_trigger_cron() { - $this->getSession()->visit($this->locate_path('/admin/cron.php')); + $this->execute('behat_general::i_visit', ['/admin/cron.php']); } /** diff --git a/lib/tests/behat/behat_hooks.php b/lib/tests/behat/behat_hooks.php index ec007f1c3c255..1e8e1e88ab575 100644 --- a/lib/tests/behat/behat_hooks.php +++ b/lib/tests/behat/behat_hooks.php @@ -496,7 +496,7 @@ public function before_step(BeforeStepScope $scope) { // Again, this would be better in the BeforeSuite hook, but that does not have access to the selectors in // order to perform the necessary searches. $session = $this->getSession(); - $session->visit($this->locate_path('/')); + $this->execute('behat_general::i_visit', ['/']); // Checking that the root path is a Moodle test site. if (self::is_first_scenario()) { diff --git a/lib/tests/behat/behat_navigation.php b/lib/tests/behat/behat_navigation.php index a2309e4edcafd..7acc898f3dc24 100644 --- a/lib/tests/behat/behat_navigation.php +++ b/lib/tests/behat/behat_navigation.php @@ -526,7 +526,7 @@ public function i_open_my_profile_in_edit_mode() { } } - $this->getSession()->visit($this->locate_path($url->out_as_local_url())); + $this->execute('behat_general::i_visit', [$url]); } // Restore global user variable. @@ -549,8 +549,7 @@ public function i_open_my_profile_in_edit_mode() { * @throws Exception if the specified page cannot be determined. */ public function i_am_on_page(string $page) { - $this->getSession()->visit($this->locate_path( - $this->resolve_page_helper($page)->out_as_local_url())); + $this->execute('behat_general::i_visit', [$this->resolve_page_helper($page)]); } /** @@ -629,8 +628,7 @@ protected function parse_page_name(string $page): array { * @throws Exception if the specified page cannot be determined. */ public function i_am_on_page_instance(string $identifier, string $type) { - $this->getSession()->visit($this->locate_path( - $this->resolve_page_instance_helper($identifier, $type)->out_as_local_url())); + $this->execute('behat_general::i_visit', [$this->resolve_page_instance_helper($identifier, $type)]); } /** @@ -753,7 +751,7 @@ public function i_am_on_course_homepage($coursefullname) { global $DB; $course = $DB->get_record("course", array("fullname" => $coursefullname), 'id', MUST_EXIST); $url = new moodle_url('/course/view.php', ['id' => $course->id]); - $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + $this->execute('behat_general::i_visit', [$url]); } /** @@ -774,13 +772,13 @@ public function i_am_on_course_homepage_with_editing_mode_on($coursefullname) { // Javascript is running so it is possible to grab the session ket and jump straight to editing mode. $url->param('edit', 1); $url->param('sesskey', $sesskey); - $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + $this->execute('behat_general::i_visit', [$url]); return; } // Visit the course page. - $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + $this->execute('behat_general::i_visit', [$url]); try { $this->execute("behat_forms::press_button", get_string('turneditingon')); @@ -1003,6 +1001,6 @@ public function i_am_on_fixture_page($url) { if (!preg_match($fixtureregex, $url)) { throw new coding_exception("URL {$url} is not a fixture URL"); } - $this->getSession()->visit($this->locate_path($url)); + $this->execute('behat_general::i_visit', [$url]); } } diff --git a/mod/forum/tests/behat/behat_mod_forum.php b/mod/forum/tests/behat/behat_mod_forum.php index 58937ced844e2..454743e9751fd 100644 --- a/mod/forum/tests/behat/behat_mod_forum.php +++ b/mod/forum/tests/behat/behat_mod_forum.php @@ -529,6 +529,6 @@ protected function goto_main_post_reply($postsubject) { global $DB; $post = $DB->get_record("forum_posts", array("subject" => $postsubject), 'id', MUST_EXIST); $url = new moodle_url('/mod/forum/post.php', ['reply' => $post->id]); - $this->getSession()->visit($this->locate_path($url->out_as_local_url(false))); + $this->execute('behat_general::i_visit', [$url]); } }