Moodle APIs
3.8
Moodle 3.8.6 (Build: 20201109)
|
Public Member Functions | |
__call ($name, $arguments) | |
Finds DOM nodes in the page using named selectors. More... | |
escape ($string) | |
Escapes the double quote character. More... | |
evaluate_script (string $script) | |
Evaluate the supplied script in the current session, returning the result. More... | |
execute_script (string $script) | |
Execute the supplied script in the current session. More... | |
get_expand_navbar_step () | |
Step to open the navigation bar if it is needed. More... | |
get_sesskey () | |
Get the session key for the current session via Javascript. More... | |
has_tag (string $tag) | |
Checks if the current scenario, or its feature, has a specified tag. More... | |
i_am_on_course_homepage ($coursefullname) | |
Opens the course homepage. More... | |
i_am_on_course_homepage_with_editing_mode_on ($coursefullname) | |
Open the course homepage with editing mode enabled. More... | |
i_am_on_page (string $page) | |
Open a given page, belonging to a plugin or core component. More... | |
i_am_on_page_instance (string $identifier, string $type) | |
Open a given instance of a page, belonging to a plugin or core component. More... | |
i_am_on_page_instance_logged_in_as (string $identifier, string $type, string $username) | |
Open a given page logged in as a given user. More... | |
i_am_on_page_logged_in_as (string $page, string $username) | |
Open a given page logged in as a given user. More... | |
i_close_flat_navigation_drawer () | |
Closes the flat navigation drawer if it is open (does nothing if JS disabled) More... | |
i_collapse_node ($nodetext) | |
Collapses the selected node of the navigation tree that matches the text. More... | |
i_expand_node ($nodetext) | |
Expands the selected node of the navigation tree that matches the text. More... | |
i_follow_in_the_user_menu ($nodetext) | |
Click on an entry in the user menu. More... | |
i_navigate_to_in_current_page_administration ($nodetext) | |
Go to current page setting item. More... | |
i_navigate_to_in_site_administration ($nodetext) | |
Go to site administration item. More... | |
i_open_flat_navigation_drawer () | |
Opens the flat navigation drawer if it is not already open. More... | |
i_open_my_profile_in_edit_mode () | |
Opens the current users profile page in edit mode. More... | |
i_select_from_flat_navigation_drawer ($link) | |
Clicks link with specified id|title|alt|text in the flat navigation drawer. More... | |
look_for_exceptions () | |
Internal step definition to find exceptions, debugging() messages and PHP debug messages. More... | |
navigation_node_should_be_expandable ($nodetext) | |
Returns true if the navigation node with the given text is expandable. More... | |
navigation_node_should_not_be_expandable ($nodetext) | |
Returns true if the navigation node with the given text is not expandable. More... | |
normalise_selector (string $selector, $locator, Element $container) | |
Normalise the locator and selector. More... | |
should_exist_in_current_page_administration ($element, $selectortype) | |
Checks that current page administration contains text. More... | |
should_not_exist_in_current_page_administration ($element, $selectortype) | |
Checks that current page administration contains text. More... | |
wait_for_pending_js () | |
Waits for all the JS to be loaded. More... | |
Static Public Member Functions | |
static | evaluate_script_in_session (Session $session, string $script) |
Evaluate the supplied script in the specified session, returning the result. More... | |
static | execute_script_in_session (Session $session, string $script) |
Excecute the supplied script in the specified session. More... | |
static | get_exact_named_selectors () |
Return a list of the exact named selectors for the component. More... | |
static | get_extended_timeout () |
Gets the extended timeout. More... | |
static | get_named_replacements () |
Return a list of the Mink named replacements for the component. More... | |
static | get_partial_named_selectors () |
Return a list of the partial named selectors for the component. More... | |
static | get_reduced_timeout () |
Gets the reduced timeout. More... | |
static | get_timeout () |
Gets the default timeout. More... | |
static | set_user ($user=null) |
Set current $USER, reset access cache. More... | |
static | wait_for_pending_js_in_session (Session $session) |
Waits for all the JS to be loaded. More... | |
Public Attributes | |
const | EXTENDED_TIMEOUT = 10 |
And extended timeout for specific cases. More... | |
const | PAGE_READY_JS |
The JS code to check that the page is ready. More... | |
const | REDUCED_TIMEOUT = 2 |
Small timeout. More... | |
const | TIMEOUT = 6 |
The timeout for each Behat step (load page, wait for an element to load...). More... | |
Protected Member Functions | |
ensure_editors_are_loaded () | |
Ensures that all the page's editors are loaded. More... | |
ensure_element_does_not_exist ($locator, $selectortype) | |
Spins until the element does not exist. More... | |
ensure_element_exists ($locator, $selectortype) | |
Spins around an element until it exists. More... | |
ensure_element_is_visible ($element, $selectortype) | |
Ensures that the provided element is visible and we can interact with it. More... | |
ensure_node_attribute_is_set ($node, $attribute, $attributevalue) | |
Ensures that the provided node has a attribute value set. More... | |
ensure_node_is_visible ($node) | |
Ensures that the provided node is visible and we can interact with it. More... | |
execute ($contextapi, $params=array()) | |
Helper function to execute api in a given context. More... | |
find ($selector, $locator, $exception=false, $node=false, $timeout=false) | |
Returns the first matching element. More... | |
find_all ($selector, $locator, $exception=false, $container=false, $timeout=false) | |
Returns all matching elements. More... | |
find_header_administration_menu ($mustexist=false) | |
Locates the administration menu in the <header> element and returns its xpath. More... | |
find_node_in_navigation ($nodetext, $parentnodes, $nodetype='link') | |
Finds a node in the Navigation or Administration tree. More... | |
find_page_administration_menu ($mustexist=false) | |
Locates the administration menu on the page (but not in the header) and returns its xpath. More... | |
get_debug_text ($html) | |
Converts HTML tags to line breaks to display the info in CLI. More... | |
get_navigation_node ($nodetext, $parentnode=null) | |
Helper function to get sub-navigation node. More... | |
get_node_in_container ($selectortype, $element, $containerselectortype, $containerelement) | |
Gets the requested element inside the specified container. More... | |
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. More... | |
get_selected_node ($selectortype, $element) | |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions. More... | |
get_session_user () | |
Get the actual user in the behat session (note $USER does not correspond to the behat session's user). More... | |
get_text_selector_node ($selectortype, $element) | |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions. More... | |
get_top_navigation_node ($nodetext) | |
Helper function to get top navigation node in tree. More... | |
go_to_main_course_page () | |
If we are not on the course main page, click on the course link in the navbar. | |
is_in_app () | |
Checks if the current page is part of the mobile app. More... | |
js_trigger_click ($node) | |
Trigger click on node via javascript instead of actually clicking on it via pointer. More... | |
locate_path ($path) | |
Locates url, based on provided path. More... | |
parse_page_name (string $page) | |
Parse a full page name like 'Admin notifications' or 'core_user > Preferences'. More... | |
require_javascript () | |
Require that javascript be available in the current Session. More... | |
resize_window ($windowsize, $viewport=false) | |
Change browser window size. More... | |
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'. More... | |
resolve_core_page_url (string $name) | |
Convert core page names to URLs for steps like 'When I am on the "[page name]" page'. More... | |
resolve_page_helper (string $page) | |
Helper used by i_am_on_page() and i_am_on_page_logged_in_as(). More... | |
resolve_page_instance_helper (string $identifier, string $pagetype) | |
Helper used by i_am_on_page() and i_am_on_page_logged_in_as(). More... | |
resolve_page_instance_url (string $type, string $identifier) | |
Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'. More... | |
resolve_page_url (string $page) | |
Convert page names to URLs for steps like 'When I am on the "[page name]" page'. More... | |
running_javascript () | |
Whether Javascript is available in the current Session. More... | |
select_from_administration_menu ($nodelist) | |
Finds a page edit cog and select an item from it. More... | |
select_node_in_navigation ($nodetext, $parentnodes) | |
Finds a node in the Navigation or Administration tree and clicks on it. More... | |
select_on_administration_page ($nodelist) | |
Finds and clicks a link on the admin page (site administration or course administration) More... | |
spin ($lambda, $args=false, $timeout=false, $exception=false, $microsleep=false) | |
Executes the passed closure until returns true or time outs. More... | |
toggle_page_administration_menu ($menuxpath=null) | |
Toggles administration menu. More... | |
transform_selector ($selectortype, $element) | |
Transforms from step definition's argument style to Mink format. More... | |
transform_text_selector ($selectortype, $element) | |
Transforms from step definition's argument style to Mink format. More... | |
Static Protected Member Functions | |
static | get_real_timeout (int $timeout) |
Gets the required timeout in seconds. More... | |
static | require_javascript_in_session (Session $session) |
Require that javascript be available for the specified Session. More... | |
static | running_javascript_in_session (Session $session) |
Whether Javascript is available in the specified Session. More... | |
|
inherited |
Finds DOM nodes in the page using named selectors.
The point of using this method instead of Mink ones is the spin method of behat_base::find() that looks for the element until it is available or it timeouts, this avoids the false failures received when selenium tries to execute commands on elements that are not ready to be used.
All steps that requires elements to be available before interact with them should use one of the find* methods.
The methods calls requires a {'find_' . $elementtype}($locator) format, like find_link($locator), find_select($locator), find_button($locator)...
@externalurl http://mink.behat.org/#named-selectors
coding_exception |
string | $name | The name of the called method |
mixed | $arguments |
NodeElement |
|
protectedinherited |
Ensures that all the page's editors are loaded.
ElementNotFoundException | |
ExpectationException |
void |
|
protectedinherited |
Spins until the element does not exist.
ExpectationException |
string | $locator | |
string | $selectortype |
void |
|
protectedinherited |
Spins around an element until it exists.
ExpectationException |
string | $locator | |
string | $selectortype |
void |
|
protectedinherited |
Ensures that the provided element is visible and we can interact with it.
Returns the node in case other actions are interested in using it.
ExpectationException |
string | $element | |
string | $selectortype |
NodeElement | Throws an exception if it times out without being visible |
|
protectedinherited |
Ensures that the provided node has a attribute value set.
This step can be used to check if specific JS has finished modifying the node.
ExpectationException |
NodeElement | $node | |
string | $attribute | attribute name |
string | $attributevalue | attribute value to check. |
void | Throws an exception if it times out without the element being visible |
|
protectedinherited |
Ensures that the provided node is visible and we can interact with it.
ExpectationException |
NodeElement | $node |
void | Throws an exception if it times out without the element being visible |
|
inherited |
Escapes the double quote character.
Double quote is the argument delimiter, it can be escaped with a backslash, but we auto-remove this backslashes before the step execution, this method is useful when using arguments as arguments for other steps.
string | $string |
string |
|
inherited |
Evaluate the supplied script in the current session, returning the result.
string | $script |
mixed |
|
staticinherited |
Evaluate the supplied script in the specified session, returning the result.
Session | $session | |
string | $script |
mixed |
|
protectedinherited |
Helper function to execute api in a given context.
string | $contextapi | context in which api is defined. |
array | $params | list of params to pass. |
Exception |
|
inherited |
Execute the supplied script in the current session.
No result will be returned.
string | $script |
|
staticinherited |
Excecute the supplied script in the specified session.
No result will be returned.
Session | $session | |
string | $script |
|
protectedinherited |
Returns the first matching element.
@externalurl http://mink.behat.org/#traverse-the-page-selectors
string | $selector | The selector type (css, xpath, named...) |
mixed | $locator | It depends on the $selector, can be the xpath, a name, a css locator... |
Exception | $exception | Otherwise we throw exception with generic info |
NodeElement | $node | Spins around certain DOM node instead of the whole page |
int | $timeout | Forces a specific time out (in seconds). |
NodeElement |
|
protectedinherited |
Returns all matching elements.
Adapter to Behat\Mink\Element\Element::findAll() using the spin() method.
@externalurl http://mink.behat.org/#traverse-the-page-selectors
string | $selector | The selector type (css, xpath, named...) |
mixed | $locator | It depends on the $selector, can be the xpath, a name, a css locator... |
Exception | $exception | Otherwise we throw expcetion with generic info |
NodeElement | $container | Restrict the search to just children of the specified container |
int | $timeout | Forces a specific time out (in seconds). If 0 is provided the default timeout will be applied. |
array | NodeElements list |
|
protected |
Locates the administration menu in the <header> element and returns its xpath.
bool | $mustexist | if specified throws an exception if menu is not found |
null|string |
|
protected |
Finds a node in the Navigation or Administration tree.
string | $nodetext | |
array | $parentnodes | |
string | $nodetype | node type (link or text) |
NodeElement|null |
ExpectationException | when one of the parent nodes is not found |
|
protected |
Locates the administration menu on the page (but not in the header) and returns its xpath.
bool | $mustexist | if specified throws an exception if menu is not found |
null|string |
Reimplemented in behat_theme_classic_behat_navigation.
|
protectedinherited |
Converts HTML tags to line breaks to display the info in CLI.
string | $html |
string |
|
staticinherited |
Return a list of the exact named selectors for the component.
Named selectors are what make Behat steps like Then I should see "Useful text" in the "General" "fieldset" work. Here, "fieldset" is the named selector, and "General" is the locator.
If you override this method in your plugin (e.g. mod_mymod), to define new selectors specific to your plugin. For example, if you returned new behat_component_named_selector('Thingy', [".//some/xpath//img[contains(@alt, %locator%)]/.."]) then Then I should see "Useful text" in the "Whatever" "mod_mymod > Thingy" would work.
This method should return a list of behat_component_named_selector and the docs on that class explain how it works.
behat_component_named_selector[] |
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$/
|
staticinherited |
Gets the extended timeout.
A longer timeout for cases where the normal timeout is not enough.
int | Timeout in seconds |
|
staticinherited |
Return a list of the Mink named replacements for the component.
Named replacements allow you to define parts of an xpath that can be reused multiple times, or in multiple xpaths.
This method should return a list of behat_component_named_replacement and the docs on that class explain how it works.
behat_component_named_replacement[] |
Reimplemented in behat_message.
|
protected |
Helper function to get sub-navigation node.
ExpectationException | if note not found. |
string | $nodetext | node to find. |
NodeElement | $parentnode | parent navigation node. |
NodeElement. |
|
protectedinherited |
Gets the requested element inside the specified container.
ElementNotFoundException | Thrown by behat_base::find |
mixed | $selectortype | The element selector type. |
mixed | $element | The element locator. |
mixed | $containerselectortype | The container selector type. |
mixed | $containerelement | The container locator. |
NodeElement |
|
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.
string | $text | |
bool | $branch | Set this true if you're only interested in the node if its a branch. |
null | bool | $collapsed | Set 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 | $exception | The exception to throw if the node is not found. |
Behat |
|
staticinherited |
Return a list of the partial named selectors for the component.
Like the exact named selectors above, but the locator only needs to match part of the text. For example, the standard "button" is a partial selector, so: When I click "Save" "button" will activate "Save changes".
behat_component_named_selector[] |
Reimplemented in behat_message.
|
staticprotectedinherited |
Gets the required timeout in seconds.
int | $timeout | One of the TIMEOUT constants |
int | Actual timeout (in seconds) |
|
staticinherited |
Gets the reduced timeout.
A reduced timeout for cases where self::get_timeout() is too much and a simple $this->getSession()->getPage()->find() could not be enough.
int | Timeout in seconds |
|
protectedinherited |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions.
Use behat_base::get_text_selector_node() for text-based selectors.
ElementNotFoundException | Thrown by behat_base::find |
string | $selectortype | |
string | $element |
NodeElement |
|
protectedinherited |
Get the actual user in the behat session (note $USER does not correspond to the behat session's user).
mixed |
coding_exception |
|
inherited |
Get the session key for the current session via Javascript.
string |
|
protectedinherited |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions.
ElementNotFoundException | Thrown by behat_base::find |
string | $selectortype | |
string | $element |
NodeElement |
|
staticinherited |
Gets the default timeout.
The timeout for each Behat step (load page, wait for an element to load...).
int | Timeout in seconds |
|
protected |
Helper function to get top navigation node in tree.
ExpectationException | if note not found. |
string | $nodetext | name of top navigation node in tree. |
NodeElement |
Reimplemented in behat_theme_classic_behat_navigation.
|
inherited |
Checks if the current scenario, or its feature, has a specified tag.
string | $tag | Tag to check |
bool | True if the tag exists in scenario or feature |
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$/
coding_exception |
string | $coursefullname | The full name of the course. |
void |
behat_navigation::i_am_on_course_homepage_with_editing_mode_on | ( | $coursefullname | ) |
Open the course homepage with editing mode enabled.
@Given /^I am on "(?P<coursefullname_string>(?:[^"]|")*)" course homepage with editing mode on$/
coding_exception |
string | $coursefullname | The course full name of the course. |
void |
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
string | $page | the component and page name. E.g. 'Admin notifications' or 'core_user > Preferences'. |
Exception | if the specified page cannot be determined. |
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
string | $identifier | identifies the particular page. E.g. 'Test quiz'. |
string | $type | the component and page type. E.g. 'mod_quiz > View'. |
Exception | if the specified page cannot be determined. |
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
string | $identifier | identifies the particular page. E.g. 'Test quiz'. |
string | $type | the component and page type. E.g. 'mod_quiz > View'. |
string | $username | the name of the user to log in as. E.g. 'student'. |
Exception | if the specified page cannot be determined. |
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
string | $page | the type of page. E.g. 'Admin notifications' or 'core_user > Preferences'. |
string | $username | the name of the user to log in as. E.g. 'admin'. |
Exception | if the specified page cannot be determined. |
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$/
ElementNotFoundException | Thrown by behat_base::find |
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$/
ExpectationException |
string | $nodetext |
bool|void |
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$/
ExpectationException |
string | $nodetext |
bool|void |
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$/
string | $nodetext |
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$/
ExpectationException |
string | $nodetext | navigation node to click, may contain path, for example "Reports > Overview" |
void |
Reimplemented in behat_theme_classic_behat_navigation.
behat_navigation::i_navigate_to_in_site_administration | ( | $nodetext | ) |
Go to site administration item.
@Given /^I navigate to "(?P<nodetext_string>(?:[^"]|")*)" in site administration$/
ExpectationException |
string | $nodetext | navigation node to click, may contain path, for example "Reports > Overview" |
void |
Reimplemented in behat_theme_classic_behat_navigation.
behat_navigation::i_open_flat_navigation_drawer | ( | ) |
Opens the flat navigation drawer if it is not already open.
@When /^I open flat navigation drawer$/
ElementNotFoundException | Thrown by behat_base::find |
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$/
coding_exception |
void |
behat_navigation::i_select_from_flat_navigation_drawer | ( | $link | ) |
Clicks link with specified id|title|alt|text in the flat navigation drawer.
@When /^I select "(?P<link_string>(?:[^"]|")*)" from flat navigation drawer$/
ElementNotFoundException | Thrown by behat_base::find |
string | $link |
|
protectedinherited |
Checks if the current page is part of the mobile app.
bool | True if it's in the app |
|
protectedinherited |
Trigger click on node via javascript instead of actually clicking on it via pointer.
This function resolves the issue of nested elements with click listeners or links - in these cases clicking via the pointer may accidentally cause a click on the wrong element. Example of issue: clicking to expand navigation nodes when the config value linkadmincategories is enabled.
NodeElement | $node |
|
protectedinherited |
Locates url, based on provided path.
Override to provide custom routing mechanism.
string | $path |
string |
|
inherited |
Internal step definition to find exceptions, debugging() messages and PHP debug messages.
Part of behat_hooks class as is part of the testing framework, is auto-executed after each step so no features will splicitly use it.
Exception | Unknown type, depending on what we caught in the hook or basic Exception. |
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$/
ExpectationException |
string | $nodetext |
bool |
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$/
ExpectationException |
string | $nodetext |
bool |
|
inherited |
Normalise the locator and selector.
string | $selector | The type of thing to search |
mixed | $locator | The locator value. Can be an array, but is more likely a string. |
Element | $container | An optional container to search within |
array | The selector, locator, and container to search within |
|
protected |
|
protectedinherited |
Require that javascript be available in the current Session.
DriverException |
|
staticprotectedinherited |
Require that javascript be available for the specified Session.
Session | $session |
DriverException |
|
protectedinherited |
Change browser window size.
string | $windowsize | size of window. |
bool | $viewport | If true, changes viewport rather than window size |
ExpectationException |
|
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 page | category idnumber | List of courses in that category. | | Course | course shortname | Main course home pag | | Activity | activity idnumber | Start page for that activity |
string | $type | identifies which type of page this is, e.g. 'Category page'. |
string | $identifier | identifies the particular page, e.g. 'test-cat'. |
moodle_url | the corresponding URL. |
Exception | with a meaningful error message if the specified page cannot be found. |
|
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. |
string | $name | identifies which identifies this page, e.g. 'Homepage', 'Admin notifications'. |
moodle_url | the corresponding URL. |
Exception | with a meaningful error message if the specified page cannot be found. |
|
protected |
Helper used by i_am_on_page() and i_am_on_page_logged_in_as().
string | $page | the type of page. E.g. 'Admin notifications' or 'core_user > Preferences'. |
moodle_url | the corresponding URL. |
|
protected |
Helper used by i_am_on_page() and i_am_on_page_logged_in_as().
string | $identifier | identifies the particular page. E.g. 'Test quiz'. |
string | $pagetype | the component and page type. E.g. 'mod_quiz > View'. |
moodle_url | the corresponding URL. |
|
protectedinherited |
Convert page names to URLs for steps like 'When I am on the "[identifier]" "[page type]" page'.
A typical example might be: When I am on the "Test quiz" "mod_quiz > Responses report" page which would cause this method in behat_mod_quiz to be called with arguments 'Responses report', 'Test quiz'.
You should override this as appropriate for your plugin. The method behat_navigation::resolve_core_page_instance_url() is a good example.
Your overridden method should document the recognised page types with a table like this:
Recognised page names are: | Type | identifier meaning | Description |
string | $type | identifies which type of page this is, e.g. 'Attempt review'. |
string | $identifier | identifies the particular page, e.g. 'Test quiz > student > Attempt 1'. |
moodle_url | the corresponding URL. |
Exception | with a meaningful error message if the specified page cannot be found. |
Reimplemented in behat_mod_quiz, and behat_core_form.
|
protectedinherited |
Convert page names to URLs for steps like 'When I am on the "[page name]" page'.
You should override this as appropriate for your plugin. The method behat_navigation::resolve_core_page_url() is a good example.
Your overridden method should document the recognised page types with a table like this:
Recognised page names are: | Page | Description |
string | $page | name of the page, with the component name removed e.g. 'Admin notification'. |
moodle_url | the corresponding URL. |
Exception | with a meaningful error message if the specified page cannot be found. |
Reimplemented in behat_mod_quiz, and behat_core_form.
|
protectedinherited |
Whether Javascript is available in the current Session.
boolean |
|
staticprotectedinherited |
Whether Javascript is available in the specified Session.
Session | $session |
boolean |
|
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
array | $nodelist |
ElementNotFoundException |
|
protected |
Finds a node in the Navigation or Administration tree and clicks on it.
string | $nodetext | |
array | $parentnodes |
ExpectationException |
|
protected |
Finds and clicks a link on the admin page (site administration or course administration)
array | $nodelist |
|
staticinherited |
Set current $USER, reset access cache.
In some cases, behat will execute the code as admin but in many cases we need to set an specific user as some API's might rely on the logged user to take some action.
null | int | stdClass | $user | user record, null or 0 means non-logged-in, positive integer means userid |
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$/
ExpectationException |
string | $element | The locator of the specified selector. This may be a path, for example "Subscription mode > Forced subscription" |
string | $selectortype | The selector type (link or text) |
void |
Reimplemented in behat_theme_classic_behat_navigation.
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$/
ExpectationException |
string | $element | The locator of the specified selector. This may be a path, for example "Subscription mode > Forced subscription" |
string | $selectortype | The selector type (link or text) |
void |
Reimplemented in behat_theme_classic_behat_navigation.
|
protectedinherited |
Executes the passed closure until returns true or time outs.
In most cases the document.readyState === 'complete' will be enough, but sometimes JS requires more time to be completely loaded or an element to be visible or whatever is required to perform some action on an element; this method receives a closure which should contain the required statements to ensure the step definition actions and assertions have all their needs satisfied and executes it until they are satisfied or it timeouts. Redirects the return of the closure to the caller.
The closures requirements to work well with this spin method are:
The arguments of the closure are mixed, use $args depending on your needs.
You can provide an exception to give more accurate feedback to tests writers, otherwise the closure exception will be used, but you must provide an exception if the closure does not throw an exception.
Exception | If it timeouts without receiving something != false from the closure |
Function | array | string | $lambda | The function to execute or an array passed to call_user_func (maps to a class method) |
mixed | $args | Arguments to pass to the closure |
int | $timeout | Timeout in seconds |
Exception | $exception | The exception to throw in case it time outs. |
bool | $microsleep | If set to true it'll sleep micro seconds rather than seconds. |
mixed | The value returned by the closure |
|
protected |
Toggles administration menu.
string | $menuxpath | (optional) xpath to the page administration menu if already known |
|
protectedinherited |
Transforms from step definition's argument style to Mink format.
Mink has 3 different selectors css, xpath and named, where named selectors includes link, button, field... to simplify and group multiple steps in one we use the same interface, considering all link, buttons... at the same level as css selectors and xpath; this method makes the conversion from the arguments received by the steps to the selectors and locators required to interact with Mink.
ExpectationException |
string | $selectortype | It can be css, xpath or any of the named selectors. |
string | $element | The locator (or string) we are looking for. |
array | Contains the selector and the locator expected by Mink. |
|
protectedinherited |
Transforms from step definition's argument style to Mink format.
Delegates all the process to behat_base::transform_selector() checking the provided $selectortype.
ExpectationException |
string | $selectortype | It can be css, xpath or any of the named selectors. |
string | $element | The locator (or string) we are looking for. |
array | Contains the selector and the locator expected by Mink. |
|
inherited |
Waits for all the JS to be loaded.
bool | Whether any JS is still pending completion. |
|
staticinherited |
Waits for all the JS to be loaded.
Session | $session | The Mink Session where JS can be run |
bool | Whether any JS is still pending completion. |
|
inherited |
And extended timeout for specific cases.
|
inherited |
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.
|
inherited |
Small timeout.
A reduced timeout for cases where self::TIMEOUT is too much and a simple $this->getSession()->getPage()->find() could not be enough.
|
inherited |
The timeout for each Behat step (load page, wait for an element to load...).