Moodle PHP Documentation 4.3
Moodle 4.3.5 (Build: 20240610) (7dcfaa79f78)
behat_navigation Class Reference

Steps definitions to navigate through the navigation tree nodes. More...

Inheritance diagram for behat_navigation:
behat_base behat_session_interface behat_theme_boost_behat_navigation behat_theme_classic_behat_navigation

Public Member Functions

 get_expand_navbar_step ()
 Step to open the navigation bar if it is needed.
 
 getSession ($name=null)
 Returns the Mink session.
 
 go_to_breadcrumb_location (string $pagename)
 First checks to see if we are on this page via the breadcrumb.
 
 i_am_on_course_homepage ($coursefullname)
 Opens the course homepage.
 
 i_am_on_course_homepage_with_editing_mode_on ($coursefullname)
 Open the course homepage with editing mode enabled.
 
 i_am_on_course_homepage_with_editing_mode_set_to (string $coursefullname, string $onoroff)
 Open the course homepage with editing mode set to either on, or off.
 
 i_am_on_fixture_page ($url)
 Visit a fixture page for testing stuff that is not available in core.
 
 i_am_on_page (string $page)
 Open a given page, belonging to a plugin or core component.
 
 i_am_on_page_instance (string $identifier, string $type)
 Open a given instance of a page, belonging to a plugin or core component.
 
 i_am_on_page_instance_logged_in_as (string $identifier, string $type, string $username)
 Open a given page logged in as a given user.
 
 i_am_on_page_logged_in_as (string $page, string $username)
 Open a given page logged in as a given user.
 
 i_close_block_drawer_if_open ()
 Close the block drawer if it is open.
 
 i_close_flat_navigation_drawer ()
 Closes the flat navigation drawer if it is open (does nothing if JS disabled)
 
 i_collapse_node ($nodetext)
 Collapses the selected node of the navigation tree that matches the text.
 
 i_expand_node ($nodetext)
 Expands the selected node of the navigation tree that matches the text.
 
 i_follow_in_the_user_menu ($nodetext)
 Click on an entry in the user menu.
 
 i_keep_block_drawer_closed ()
 I close the block drawer and keep it closed.
 
 i_navigate_to_in_current_page_administration ($nodetext)
 Go to current page setting item.
 
 i_navigate_to_in_site_administration ($nodetext)
 Go to site administration item.
 
 i_open_a_tab_on_the_current_page (string $name)
 Opens a new tab with given name on the same URL as current page and switches to it.
 
 i_open_a_tab_on_the_page (string $name, string $page)
 Opens a new tab with given name on specified page, and switches to it.
 
 i_open_a_tab_on_the_page_instance (string $name, string $identifier, string $page)
 Opens a new tab with given name (on specified page), and switches to it.
 
 i_open_flat_navigation_drawer ()
 Opens the flat navigation drawer if it is not already open.
 
 i_open_my_profile_in_edit_mode ()
 Opens the current users profile page in edit mode.
 
 i_select_from_primary_navigation (string $link)
 Clicks link with specified id|title|alt|text in the primary navigation.
 
 i_select_from_secondary_navigation (string $link)
 Clicks link with specified id|title|alt|text in the secondary navigation.
 
 i_should_see_is_active_in_navigation ($element)
 Checks whether a navigation node is active within the block navigation.
 
 i_should_see_user_submenu ($submenuname)
 Checks whether a given user submenu is visible.
 
 i_turn_editing_mode_off ()
 Turns editing mode off.
 
 i_turn_editing_mode_on ()
 Turns editing mode on.
 
 navigation_node_should_be_expandable ($nodetext)
 Returns true if the navigation node with the given text is expandable.
 
 navigation_node_should_not_be_expandable ($nodetext)
 Returns true if the navigation node with the given text is not expandable.
 
 should_exist_in_current_page_administration ($element, $selectortype)
 Checks that current page administration contains text.
 
 should_exist_in_dropdown (string $item, bool $not, string $dropdown, string $container=null, string $containertype=null,)
 The named item should exist in the named dropdown.
 
 should_exist_in_dropdown_in (string $item, string $dropdown, null|NodeElement $container, bool $not,)
 Helper to check whether an item exists in a dropdown.
 
 should_exist_in_user_menu ($itemtext, $selectortype, $not=null)
 Checks whether an item exists in the user menu.
 
 should_exist_in_user_submenu ($itemtext, $selectortype, $submenuname, $not=null)
 Checks whether an item exists in a given user submenu.
 
 should_not_exist_in_current_page_administration ($element, $selectortype)
 Checks that current page administration contains text.
 

Public Attributes

const PAGE_READY_JS
 The JS code to check that the page is ready.
 

Protected Member Functions

 find_header_administration_menu ($mustexist=false)
 Locates the administration menu in the <header> element and returns its xpath.
 
 find_node_in_navigation ($nodetext, $parentnodes, $nodetype='link')
 Finds a node in the Navigation or Administration tree.
 
 find_page_action_menu ($mustexist=false)
 Locates the action menu on the page (but not in the header) and returns its xpath.
 
 find_page_administration_menu ($mustexist=false)
 Locates the administration menu on the page (but not in the header) and returns its xpath.
 
 get_navigation_node ($nodetext, $parentnode=null)
 Helper function to get sub-navigation node.
 
 get_node_text_node ($text, $branch=false, $collapsed=null, $exception=null)
 Helper function to get a navigation nodes text element given its text from within the navigation block.
 
 get_top_navigation_node ($nodetext)
 Helper function to get top navigation node in tree.
 
 get_user_menu_xpath ()
 Return the xpath for the user menu element.
 
 get_user_submenu_xpath ($submenuname)
 Return the xpath for a given user submenu element.
 
 go_to_main_course_page ()
 If we are not on the course main page, click on the course link in the navbar.
 
 is_editing_on ()
 Returns whether the user can edit the current page.
 
 open_tab (string $name, string $jstarget)
 Opens a new tab at the given target URL.
 
 parse_page_name (string $page)
 Parse a full page name like 'Admin notifications' or 'core_user > Preferences'.
 
 resolve_core_page_instance_url (string $type, string $identifier)
 Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
 
 resolve_core_page_url (string $name)
 Convert core page names to URLs for steps like 'When I am on the "[page name]" page'.
 
 resolve_page_helper (string $page)
 Helper used by i_am_on_page() and i_am_on_page_logged_in_as().
 
 resolve_page_instance_helper (string $identifier, string $pagetype)
 Helper used by i_am_on_page() and i_am_on_page_logged_in_as().
 
 select_from_administration_menu ($nodelist)
 Finds a page edit cog and select an item from it.
 
 select_node_in_navigation ($nodetext, $parentnodes)
 Finds a node in the Navigation or Administration tree and clicks on it.
 
 select_on_administration_page ($nodelist)
 Finds and clicks a link on the admin page (site administration or course administration)
 
 toggle_page_administration_menu ($menuxpath=null)
 Toggles administration menu.
 

Detailed Description

Steps definitions to navigate through the navigation tree nodes.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ find_header_administration_menu()

behat_navigation::find_header_administration_menu ( $mustexist = false)
protected

Locates the administration menu in the <header> element and returns its xpath.

Parameters
bool$mustexistif specified throws an exception if menu is not found
Return values
null|string

◆ find_node_in_navigation()

behat_navigation::find_node_in_navigation ( $nodetext,
$parentnodes,
$nodetype = 'link' )
protected

Finds a node in the Navigation or Administration tree.

Parameters
string$nodetext
array$parentnodes
string$nodetypenode type (link or text)
Return values
NodeElement|null
Exceptions
ExpectationExceptionwhen one of the parent nodes is not found

◆ find_page_action_menu()

behat_navigation::find_page_action_menu ( $mustexist = false)
protected

Locates the action menu on the page (but not in the header) and returns its xpath.

Parameters
null | bool$mustexistif specified throws an exception if menu is not found
Return values
null|string

◆ find_page_administration_menu()

behat_navigation::find_page_administration_menu ( $mustexist = false)
protected

Locates the administration menu on the page (but not in the header) and returns its xpath.

Parameters
bool$mustexistif specified throws an exception if menu is not found
Return values
null|string

◆ get_expand_navbar_step()

behat_navigation::get_expand_navbar_step ( )

Step to open the navigation bar if it is needed.

The top log in and log out links are hidden when middle or small size windows (or devices) are used. This step returns a step definition clicking to expand the navbar if it is hidden.

@Given /^I expand navigation bar$/

◆ get_navigation_node()

behat_navigation::get_navigation_node ( $nodetext,
$parentnode = null )
protected

Helper function to get sub-navigation node.

Exceptions
ExpectationExceptionif note not found.
Parameters
string$nodetextnode to find.
NodeElement$parentnodeparent navigation node.
Return values
NodeElement.

◆ get_node_text_node()

behat_navigation::get_node_text_node ( $text,
$branch = false,
$collapsed = null,
$exception = null )
protected

Helper function to get a navigation nodes text element given its text from within the navigation block.

This function finds the node with the given text from within the navigation block. It checks to make sure the node is visible, and then returns it.

Parameters
string$text
bool$branchSet this true if you're only interested in the node if its a branch.
null | bool$collapsedSet this to true or false if you want the node to either be collapsed or not. If its left as null then we don't worry about it.
null | string | Exception | false$exceptionThe exception to throw if the node is not found.
Return values
Behat\Mink\Element\NodeElement

◆ get_top_navigation_node()

behat_navigation::get_top_navigation_node ( $nodetext)
protected

Helper function to get top navigation node in tree.

Exceptions
ExpectationExceptionif note not found.
Parameters
string$nodetextname of top navigation node in tree.
Return values
NodeElement

Reimplemented in behat_theme_classic_behat_navigation.

◆ get_user_menu_xpath()

behat_navigation::get_user_menu_xpath ( )
protected

Return the xpath for the user menu element.

Return values
stringThe xpath

◆ get_user_submenu_xpath()

behat_navigation::get_user_submenu_xpath ( $submenuname)
protected

Return the xpath for a given user submenu element.

Parameters
string$submenunameThe name of the submenu
Return values
stringThe xpath

◆ getSession()

behat_session_interface::getSession ( $name = null)
inherited

Returns the Mink session.

Parameters
string | null$namename of the session OR active session will be used
Return values
Behat\Mink\Session

Implemented in behat_form_field.

◆ go_to_breadcrumb_location()

behat_navigation::go_to_breadcrumb_location ( string $pagename)

First checks to see if we are on this page via the breadcrumb.

If not we then attempt to follow the link name given.

Parameters
string$pagenameName of the breadcrumb item to check and follow. @Given /^I follow the breadcrumb "(?P<url_string>(?:[^"]|::")*)"$/

◆ i_am_on_course_homepage()

behat_navigation::i_am_on_course_homepage ( $coursefullname)

Opens the course homepage.

(Consider using 'I am on the "shortname" "Course" page' step instead.)

@Given /^I am on "(?P<coursefullname_string>(?:[^"]|::")*)" course homepage$/

Exceptions
coding_exception
Parameters
string$coursefullnameThe full name of the course.
Return values
void

◆ i_am_on_course_homepage_with_editing_mode_on()

behat_navigation::i_am_on_course_homepage_with_editing_mode_on ( $coursefullname)

Open the course homepage with editing mode enabled.

Parameters
string$coursefullnameThe course full name of the course.

◆ i_am_on_course_homepage_with_editing_mode_set_to()

behat_navigation::i_am_on_course_homepage_with_editing_mode_set_to ( string $coursefullname,
string $onoroff )

Open the course homepage with editing mode set to either on, or off.

@Given I am on :coursefullname course homepage with editing mode :onoroff

Exceptions
coding_exception
Parameters
string$coursefullnameThe course full name of the course.
string$onoroffWhehter to switch editing on, or off.

◆ i_am_on_fixture_page()

behat_navigation::i_am_on_fixture_page ( $url)

Visit a fixture page for testing stuff that is not available in core.

Please always, to prevent unwanted requests, protect behat fixture files with: defined('BEHAT_SITE_RUNNING') || die();

@Given /^I am on fixture page "(?P<url_string>(?:[^"]|::")*)"$/

Parameters
string$urllocal path to fixture page

◆ i_am_on_page()

behat_navigation::i_am_on_page ( string $page)

Open a given page, belonging to a plugin or core component.

The page-type are interpreted by each plugin to work out the corresponding URL. See the resolve_url method in each class like behat_mod_forum. That method should document which page types are recognised, and how the name identifies them.

For pages belonging to core, the 'core > ' bit is omitted.

@When /^I am on the (?<page>[^ "]*) page$/ @When /^I am on the "(?<page>[^"]*)" page$/

Parameters
string$pagethe component and page name. E.g. 'Admin notifications' or 'core_user > Preferences'.
Exceptions
Exceptionif the specified page cannot be determined.

◆ i_am_on_page_instance()

behat_navigation::i_am_on_page_instance ( string $identifier,
string $type )

Open a given instance of a page, belonging to a plugin or core component.

The instance identifier and page-type are interpreted by each plugin to work out the corresponding URL. See the resolve_page_instance_url method in each class like behat_mod_forum. That method should document which page types are recognised, and how the name identifies them.

For pages belonging to core, the 'core > ' bit is omitted.

@When /^I am on the (?<identifier>[^ "]*) (?<type>[^ "]*) page$/ @When /^I am on the "(?<identifier>[^"]*)" "(?<type>[^"]*)" page$/ @When /^I am on the (?<identifier>[^ "]*) "(?<type>[^"]*)" page$/ @When /^I am on the "(?<identifier>[^"]*)" (?<type>[^ "]*) page$/

Parameters
string$identifieridentifies the particular page. E.g. 'Test quiz'.
string$typethe component and page type. E.g. 'mod_quiz > View'.
Exceptions
Exceptionif the specified page cannot be determined.

◆ i_am_on_page_instance_logged_in_as()

behat_navigation::i_am_on_page_instance_logged_in_as ( string $identifier,
string $type,
string $username )

Open a given page logged in as a given user.

This is like the combination When I log in as "..." And I am on the "..." "..." page but with the advantage that you go straight to the desired page, without having to wait for the Dashboard to load.

@When /^I am on the (?<identifier>[^ "]*) (?<type>[^ "]*) page logged in as (?<username>[^ "]*)$/ @When /^I am on the "(?<identifier>[^"]*)" "(?<type>[^"]*)" page logged in as (?<username>[^ "]*)$/ @When /^I am on the (?<identifier>[^ "]*) "(?<type>[^"]*)" page logged in as (?<username>[^ "]*)$/ @When /^I am on the "(?<identifier>[^"]*)" (?<type>[^ "]*) page logged in as (?<username>[^ "]*)$/ @When /^I am on the (?<identifier>[^ "]*) (?<type>[^ "]*) page logged in as "(?<username>[^"]*)"$/ @When /^I am on the "(?<identifier>[^"]*)" "(?<type>[^"]*)" page logged in as "(?<username>[^"]*)"$/ @When /^I am on the (?<identifier>[^ "]*) "(?<type>[^"]*)" page logged in as "(?<username>[^"]*)"$/ @When /^I am on the "(?<identifier>[^"]*)" (?<type>[^ "]*) page logged in as "(?<username>[^"]*)"$/

Parameters
string$identifieridentifies the particular page. E.g. 'Test quiz'.
string$typethe component and page type. E.g. 'mod_quiz > View'.
string$usernamethe name of the user to log in as. E.g. 'student'.
Exceptions
Exceptionif the specified page cannot be determined.

◆ i_am_on_page_logged_in_as()

behat_navigation::i_am_on_page_logged_in_as ( string $page,
string $username )

Open a given page logged in as a given user.

This is like the combination When I log in as "..." And I am on the "..." page but with the advantage that you go straight to the desired page, without having to wait for the Dashboard to load.

@When /^I am on the (?<page>[^ "]*) page logged in as (?<username>[^ "]*)$/ @When /^I am on the "(?<page>[^"]*)" page logged in as (?<username>[^ "]*)$/ @When /^I am on the (?<page>[^ "]*) page logged in as "(?<username>[^ "]*)"$/ @When /^I am on the "(?<page>[^"]*)" page logged in as "(?<username>[^ "]*)"$/

Parameters
string$pagethe type of page. E.g. 'Admin notifications' or 'core_user > Preferences'.
string$usernamethe name of the user to log in as. E.g. 'admin'.
Exceptions
Exceptionif the specified page cannot be determined.

◆ i_close_block_drawer_if_open()

behat_navigation::i_close_block_drawer_if_open ( )

Close the block drawer if it is open.

This is necessary as in Behat the block drawer is open at each page load (disregarding user's settings) As the block drawer is positioned at the front of some contextual dialogs on the grade report for example. @Given I close block drawer if open

Return values
void

◆ i_close_flat_navigation_drawer()

behat_navigation::i_close_flat_navigation_drawer ( )

Closes the flat navigation drawer if it is open (does nothing if JS disabled)

@When /^I close flat navigation drawer$/

Exceptions
ElementNotFoundExceptionThrown by behat_base\find

◆ i_collapse_node()

behat_navigation::i_collapse_node ( $nodetext)

Collapses the selected node of the navigation tree that matches the text.

@Given /^I collapse "(?P<nodetext_string>(?:[^"]|::")*)" node$/

Exceptions
ExpectationException
Parameters
string$nodetext
Return values
bool|void

◆ i_expand_node()

behat_navigation::i_expand_node ( $nodetext)

Expands the selected node of the navigation tree that matches the text.

@Given /^I expand "(?P<nodetext_string>(?:[^"]|::")*)" node$/

Exceptions
ExpectationException
Parameters
string$nodetext
Return values
bool|void

◆ i_follow_in_the_user_menu()

behat_navigation::i_follow_in_the_user_menu ( $nodetext)

Click on an entry in the user menu.

@Given /^I follow "(?P<nodetext_string>(?:[^"]|::")*)" in the user menu$/

Parameters
string$nodetext

◆ i_keep_block_drawer_closed()

behat_navigation::i_keep_block_drawer_closed ( )

I close the block drawer and keep it closed.

@Given I keep block drawer closed

Return values
void

◆ i_navigate_to_in_current_page_administration()

behat_navigation::i_navigate_to_in_current_page_administration ( $nodetext)

Go to current page setting item.

This can be used on front page, course, category or modules pages.

@Given /^I navigate to "(?P<nodetext_string>(?:[^"]|::")*)" in current page administration$/

Exceptions
ExpectationException
Parameters
string$nodetextnavigation node to click, may contain path, for example "Reports > Overview"
Return values
void

Reimplemented in behat_theme_classic_behat_navigation.

◆ i_navigate_to_in_site_administration()

behat_navigation::i_navigate_to_in_site_administration ( $nodetext)

Go to site administration item.

@Given /^I navigate to "(?P<nodetext_string>(?:[^"]|::")*)" in site administration$/

Exceptions
ExpectationException
Parameters
string$nodetextnavigation node to click, may contain path, for example "Reports > Overview"
Return values
void

Reimplemented in behat_theme_classic_behat_navigation.

◆ i_open_a_tab_on_the_current_page()

behat_navigation::i_open_a_tab_on_the_current_page ( string $name)

Opens a new tab with given name on the same URL as current page and switches to it.

Parameters
string$nameTab name that can be used for switching later (no whitespace) @When /^I open a tab named "(?<name>[^"]*)" on the current page$/

◆ i_open_a_tab_on_the_page()

behat_navigation::i_open_a_tab_on_the_page ( string $name,
string $page )

Opens a new tab with given name on specified page, and switches to it.

Parameters
string$nameTab name that can be used for switching later (no whitespace)
string$pagePage name @When /^I open a tab named "(?<name>[^"]*)" on the "(?<page>[^"]*)" page$/

◆ i_open_a_tab_on_the_page_instance()

behat_navigation::i_open_a_tab_on_the_page_instance ( string $name,
string $identifier,
string $page )

Opens a new tab with given name (on specified page), and switches to it.

Parameters
string$nameTab name that can be used for switching later (no whitespace)
string$identifierPage identifier
string$pagePage type @When /^I open a tab named "(?<name>[^"]*)" on the "(?<identifier>[^"]*)" "(?<page>[^"]*)" page$/

◆ i_open_flat_navigation_drawer()

behat_navigation::i_open_flat_navigation_drawer ( )

Opens the flat navigation drawer if it is not already open.

@When /^I open flat navigation drawer$/

Exceptions
ElementNotFoundExceptionThrown by behat_base\find

◆ i_open_my_profile_in_edit_mode()

behat_navigation::i_open_my_profile_in_edit_mode ( )

Opens the current users profile page in edit mode.

@Given /^I open my profile in edit mode$/

Exceptions
coding_exception
Return values
void

◆ i_select_from_primary_navigation()

behat_navigation::i_select_from_primary_navigation ( string $link)

Clicks link with specified id|title|alt|text in the primary navigation.

@When /^I select "(?P<link_string>(?:[^"]|::")*)" from primary navigation$/

Exceptions
ElementNotFoundExceptionThrown by behat_base\find
Parameters
string$link

◆ i_select_from_secondary_navigation()

behat_navigation::i_select_from_secondary_navigation ( string $link)

Clicks link with specified id|title|alt|text in the secondary navigation.

@When I select :link from secondary navigation

Exceptions
ElementNotFoundExceptionThrown by behat_base\find
Parameters
string$link

◆ i_should_see_is_active_in_navigation()

behat_navigation::i_should_see_is_active_in_navigation ( $element)

Checks whether a navigation node is active within the block navigation.

@Given i should see :name is active in navigation

Exceptions
ElementNotFoundException
Parameters
string$elementThe name of the nav elemnent to look for.
Return values
void

Reimplemented in behat_theme_boost_behat_navigation.

◆ i_should_see_user_submenu()

behat_navigation::i_should_see_user_submenu ( $submenuname)

Checks whether a given user submenu is visible.

@Then /^I should see "(?P<submenu_string>[^"]*)" user submenu$/

Exceptions
ElementNotFoundException
ExpectationException
Parameters
string$submenunameThe name of the submenu
Return values
void

◆ i_turn_editing_mode_off()

behat_navigation::i_turn_editing_mode_off ( )

Turns editing mode off.

@Given I switch editing mode off @Given I turn editing mode off

◆ i_turn_editing_mode_on()

behat_navigation::i_turn_editing_mode_on ( )

Turns editing mode on.

@Given I switch editing mode on @Given I turn editing mode on

◆ is_editing_on()

behat_navigation::is_editing_on ( )
protected

Returns whether the user can edit the current page.

Return values
bool

◆ navigation_node_should_be_expandable()

behat_navigation::navigation_node_should_be_expandable ( $nodetext)

Returns true if the navigation node with the given text is expandable.

@Given /^navigation node "([^"]*)" should be expandable$/

Exceptions
ExpectationException
Parameters
string$nodetext
Return values
bool

◆ navigation_node_should_not_be_expandable()

behat_navigation::navigation_node_should_not_be_expandable ( $nodetext)

Returns true if the navigation node with the given text is not expandable.

@Given /^navigation node "([^"]*)" should not be expandable$/

Exceptions
ExpectationException
Parameters
string$nodetext
Return values
bool

◆ open_tab()

behat_navigation::open_tab ( string $name,
string $jstarget )
protected

Opens a new tab at the given target URL.

Parameters
string$nameName for tab
string$jstargetTarget in JavaScript syntax, i.e. if a string, must be quoted

◆ parse_page_name()

behat_navigation::parse_page_name ( string $page)
protected

Parse a full page name like 'Admin notifications' or 'core_user > Preferences'.

E.g. parsing 'mod_quiz > View' gives ['mod_quiz', 'View'].

Parameters
string$pagethe full page name
Return values
arraywith two elements, component and page name.

◆ resolve_core_page_instance_url()

behat_navigation::resolve_core_page_instance_url ( string $type,
string $identifier )
protected

Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.

Recognised page names are: | Page type | Identifier meaning | description | | Category | category idnumber | List of courses in that category. | | Course | course shortname | Main course home pag | | Course editing | course shortname | Edit settings page for the course | | Activity | activity idnumber | Start page for that activity | | Activity editing | activity idnumber | Edit settings page for that activity | | [modname] Activity | activity name or idnumber | Start page for that activity | | [modname] Activity editing | activity name or idnumber | Edit settings page for that activity | | Backup | course shortname | Course to backup | | Import | course shortname | Course import from | | Restore | course shortname | Course to restore from | | Reset | course shortname | Course to reset | | Course copy | course shortname | Course to copy | | Groups | course shortname | Groups page for the course | | Groups overview | course shortname | Groups overview page for the course | | Groupings | course shortname | Groupings page for the course | | Permissions | course shortname | Permissions page for the course | | Enrolment methods | course shortname | Enrolment methods for the course | | Enrolled users | course shortname | The main participants page | | Other users | course shortname | The course other users page | | Course profile | course shortname | The current user's profile for this course | | Course profile editing | course shortname | The current user's profile editing page for this course | | Course profile advanced editing | course shortname | The current user's advanced profile editing page for this course |

Examples:

When I am on the "Welcome to ECON101" "forum activity" page logged in as student1

Parameters
string$typeidentifies which type of page this is, e.g. 'Category page'.
string$identifieridentifies the particular page, e.g. 'test-cat'.
Return values
moodle_urlthe corresponding URL.
Exceptions
Exceptionwith a meaningful error message if the specified page cannot be found.

◆ resolve_core_page_url()

behat_navigation::resolve_core_page_url ( string $name)
protected

Convert core page names to URLs for steps like 'When I am on the "[page name]" page'.

Recognised page names are: | Homepage | Homepage (normally dashboard). | | Admin notifications | Admin notification screen. |

Parameters
string$nameidentifies which identifies this page, e.g. 'Homepage', 'Admin notifications'.
Return values
moodle_urlthe corresponding URL.
Exceptions
Exceptionwith a meaningful error message if the specified page cannot be found.

◆ resolve_page_helper()

behat_navigation::resolve_page_helper ( string $page)
protected

Helper used by i_am_on_page() and i_am_on_page_logged_in_as().

Parameters
string$pagethe type of page. E.g. 'Admin notifications' or 'core_user > Preferences'.
Return values
moodle_urlthe corresponding URL.

◆ resolve_page_instance_helper()

behat_navigation::resolve_page_instance_helper ( string $identifier,
string $pagetype )
protected

Helper used by i_am_on_page() and i_am_on_page_logged_in_as().

Parameters
string$identifieridentifies the particular page. E.g. 'Test quiz'.
string$pagetypethe component and page type. E.g. 'mod_quiz > View'.
Return values
moodle_urlthe corresponding URL.

◆ select_from_administration_menu()

behat_navigation::select_from_administration_menu ( $nodelist)
protected

Finds a page edit cog and select an item from it.

If the page edit cog is in the page header and the item is not found there, click "More..." link and find the item on the course/frontpage administration page

Parameters
array$nodelist
Exceptions
ElementNotFoundException

◆ select_node_in_navigation()

behat_navigation::select_node_in_navigation ( $nodetext,
$parentnodes )
protected

Finds a node in the Navigation or Administration tree and clicks on it.

Parameters
string$nodetext
array$parentnodes
Exceptions
ExpectationException

◆ select_on_administration_page()

behat_navigation::select_on_administration_page ( $nodelist)
protected

Finds and clicks a link on the admin page (site administration or course administration)

Parameters
array$nodelist

◆ should_exist_in_current_page_administration()

behat_navigation::should_exist_in_current_page_administration ( $element,
$selectortype )

Checks that current page administration contains text.

@Given /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should exist in current page administration$/ @throws ExpectationException @param string $element The locator of the specified selector. This may be a path, for example "Subscription mode > Forced subscription"

Parameters
string$selectortypeThe selector type (link or text)
Return values
void

Reimplemented in behat_theme_classic_behat_navigation.

◆ should_exist_in_dropdown()

behat_navigation::should_exist_in_dropdown ( string $item,
bool $not,
string $dropdown,
string $container = null,
string $containertype = null )

The named item should exist in the named dropdown.

@Then /^the "(?P<item_string>[^"]*)" item should (?P<not_bool>not )?exist in the "(?P<dropdown_string>[^"]*)" dropdown$/ @Then /^the "(?P<item_string>[^"]*)" item should (?P<not_bool>not )?exist in the "(?P<dropdown_string>[^"]*)" dropdown of the "(?P<container_string>[^"]*)" "(?P<containertype_string>[^"]*)"$/

Parameters
string$itemThe text on the dropdown menu item
bool$notWhether to negate this search
string$dropdownThe name of the dropdown
string$containerThe name of the container
string$containertypeThe type of the container

◆ should_exist_in_dropdown_in()

behat_navigation::should_exist_in_dropdown_in ( string $item,
string $dropdown,
null|NodeElement $container,
bool $not )

Helper to check whether an item exists in a dropdown.

Parameters
string$itemThe text of the item to look for
string$dropdownThe name of the dropdown
null | NodeElement$containerThe container to look within

◆ should_exist_in_user_menu()

behat_navigation::should_exist_in_user_menu ( $itemtext,
$selectortype,
$not = null )

Checks whether an item exists in the user menu.

@Given :itemtext :selectortype should exist in the user menu @Given :itemtext :selectortype should :not exist in the user menu

Exceptions
ElementNotFoundException
Parameters
string$itemtextThe menu item to find
string$selectortypeThe selector type
string | null$notInstructs to checks whether the element does not exist in the user menu, if defined
Return values
void

◆ should_exist_in_user_submenu()

behat_navigation::should_exist_in_user_submenu ( $itemtext,
$selectortype,
$submenuname,
$not = null )

Checks whether an item exists in a given user submenu.

@Given :itemtext :selectortype should exist in the :submenuname user submenu @Given :itemtext :selectortype should :not exist in the :submenuname user submenu

Exceptions
ElementNotFoundException
Parameters
string$itemtextThe submenu item to find
string$selectortypeThe selector type
string$submenunameThe name of the submenu
string | null$notInstructs to checks whether the element does not exist in the user menu, if defined
Return values
void

◆ should_not_exist_in_current_page_administration()

behat_navigation::should_not_exist_in_current_page_administration ( $element,
$selectortype )

Checks that current page administration contains text.

@Given /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should not exist in current page administration$/ @throws ExpectationException @param string $element The locator of the specified selector. This may be a path, for example "Subscription mode > Forced subscription"

Parameters
string$selectortypeThe selector type (link or text)
Return values
void

◆ toggle_page_administration_menu()

behat_navigation::toggle_page_administration_menu ( $menuxpath = null)
protected

Toggles administration menu.

Parameters
string$menuxpath(optional) xpath to the page administration menu if already known

Member Data Documentation

◆ PAGE_READY_JS

const behat_session_interface::PAGE_READY_JS
inherited
Initial value:
= "document.readyState === 'complete' && " .
"(typeof M !== 'object' || typeof M.util !== 'object' || " .
"typeof M.util.pending_js === 'undefined' || M.util.pending_js.length === 0)"

The JS code to check that the page is ready.

The document must be complete and either M.util.pending_js must be empty, or it must not be defined at all.


The documentation for this class was generated from the following file: