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... | |
actions_menu_should_be_open ($activityname) | |
Checks that the specified activity's action menu is open. More... | |
actions_menu_should_have_item ($activityname, $menuitem) | |
Checks that the specified activity's action menu contains an item. More... | |
actions_menu_should_not_have_item ($activityname, $menuitem) | |
Checks that the specified activity's action menu does not contains an item. More... | |
activity_should_be_available_but_hidden_from_course_page ($activityname) | |
Checks that the specified activity is visible. More... | |
activity_should_be_dimmed ($activityname) | |
Checks that the specified activity is dimmed. More... | |
activity_should_be_hidden ($activityname) | |
Checks that the specified activity is hidden. More... | |
activity_should_be_visible ($activityname) | |
Checks that the specified activity is visible. More... | |
category_in_management_listing_should_be_dimmed ($idnumber) | |
Checks that a category within the management interface is dimmed. More... | |
category_in_management_listing_should_be_visible ($idnumber) | |
Checks that a category within the management interface is visible. More... | |
course_in_management_listing_should_be_dimmed ($idnumber) | |
Checks that a course within the management interface is dimmed. More... | |
course_in_management_listing_should_be_visible ($idnumber) | |
Checks that a course within the management interface is visible. 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_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_add_to_section ($activity, $section) | |
Opens the activity chooser and opens the activity/resource form page. More... | |
i_add_to_section_and_i_fill_the_form_with ($activity, $section, TableNode $data) | |
Adds the selected activity/resource filling the form data with the specified field/value pairs. More... | |
i_change_activity_name_to ($activityname, $newactivityname) | |
Edits the activity name through the edit activity; this step only works with Javascript enabled. More... | |
i_click_on_action_for_item_in_management_category_listing ($action, $name) | |
Locates a category in the course category management interface and then triggers an action for it. More... | |
i_click_on_action_for_item_in_management_course_listing ($action, $name) | |
Locates a course in the course category management interface and then triggers an action for it. More... | |
i_click_on_category_in_the_management_category_listing ($name) | |
Clicks on a category in the management interface. More... | |
i_click_on_category_in_the_management_interface ($name) | |
Clicks on a category in the management interface. More... | |
i_click_on_course_in_the_management_interface ($name) | |
Clicks on a course in the management interface. More... | |
i_click_on_in_the_activity ($element, $selectortype, $activityname) | |
Clicks on the specified element of the activity. More... | |
i_click_to_expand_category_in_the_management_interface ($idnumber) | |
Click to expand a category revealing its sub categories within the management UI. More... | |
i_click_to_move_category_by_one ($idnumber, $direction) | |
Moves a category displayed in the management interface up or down one place. More... | |
i_click_to_move_course_by_one ($idnumber, $direction) | |
Moves a course displayed in the management interface up or down one place. More... | |
i_close_actions_menu ($activityname) | |
Closes an activity actions menu if it is not already closed. More... | |
i_create_a_course_with (TableNode $table) | |
Creates a new course with the provided table data matching course settings names with the desired values. More... | |
i_delete_activity ($activityname) | |
Deletes the activity or resource specified by it's name. More... | |
i_delete_section ($sectionnumber) | |
Deletes course section. More... | |
i_duplicate_activity ($activityname) | |
Duplicates the activity or resource specified by it's name. More... | |
i_duplicate_activity_editing_the_new_copy_with ($activityname, TableNode $data) | |
Duplicates the activity or resource and modifies the new activity with the provided data. More... | |
i_edit_the_section ($sectionnumber) | |
Go to editing section page for specified section number. More... | |
i_edit_the_section_and_i_fill_the_form_with ($sectionnumber, TableNode $data) | |
Edit specified section and fill the form data with the specified field/value pairs. More... | |
i_go_to_the_courses_management_page () | |
Goes to the system courses/categories management page. More... | |
i_hide_section ($sectionnumber) | |
Hides the specified visible section. More... | |
i_indent_left_activity ($activityname) | |
Indents to the left the activity or resource specified by it's name. More... | |
i_indent_right_activity ($activityname) | |
Indents to the right the activity or resource specified by it's name. More... | |
i_move_activity_to_section ($activityname, $sectionnumber) | |
Moves the specified activity to the first slot of a section. More... | |
i_move_category_to_top_level_in_the_management_interface ($name) | |
Move selected categories to top level in the management interface. More... | |
i_move_down_section ($sectionnumber) | |
Moves down the specified section, this step only works with Javascript disabled. More... | |
i_move_up_section ($sectionnumber) | |
Moves up the specified section, this step only works with Javascript disabled. More... | |
i_navigate_to_course_participants () | |
Go to the course participants. | |
i_open_actions_menu ($activityname) | |
Opens an activity actions menu if it is not already opened. More... | |
i_open_section_edit_menu ($sectionnumber) | |
Opens a section edit menu if it is not already opened. More... | |
i_select_category_in_the_management_interface ($name) | |
Clicks on a category checkbox in the management interface, if not checked. More... | |
i_select_course_in_the_management_interface ($name) | |
Clicks course checkbox in the management interface, if not checked. More... | |
i_should_not_see_category_as_subcategory_of_in_the_management_interface ($subcatidnumber, $catidnumber) | |
Checks that a category is not a subcategory of specific category. More... | |
i_should_not_see_teacher_after ($fteacher, $pteacher) | |
Check that one teacher oes not appears after another in the course contacts. More... | |
i_should_see_category_as_subcategory_of_in_the_management_interface ($subcatidnumber, $catidnumber) | |
Checks that a category is a subcategory of specific category. More... | |
i_should_see_category_listing_before ($preceedingcategory, $followingcategory) | |
Check that one category appears before another in the course category management listings. More... | |
i_should_see_course_listing_before ($preceedingcourse, $followingcourse) | |
Check that one course appears before another in the course category management listings. More... | |
i_should_see_teacher_before ($pteacher, $fteacher) | |
Check that one teacher appears before another in the course contacts. More... | |
i_should_see_the_courses_management_page ($mode) | |
Checks that we are on the course management page that we expect to be on and that no course has been selected. More... | |
i_should_see_the_courses_management_page_with_a_course_selected ($mode) | |
Checks that we are on the course management page that we expect to be on and that a course has been selected. More... | |
i_show_section ($sectionnumber) | |
Shows the specified hidden section. More... | |
i_toggle_category_children_visibility_in_frontpage ($categoryname) | |
Clicks to expand or collapse a category displayed on the frontpage. More... | |
i_toggle_visibility_of_category_in_management_listing ($idnumber) | |
Toggles the visibility of a category in the management UI. More... | |
i_toggle_visibility_of_course_in_management_listing ($idnumber) | |
Toggles the visibility of a course in the management UI. More... | |
i_turn_editing_mode_off () | |
Turns editing mode off. More... | |
i_turn_editing_mode_on () | |
Turns editing mode on. More... | |
i_turn_section_highlighting_off ($sectionnumber) | |
Turns course section highlighting off. More... | |
i_turn_section_highlighting_on ($sectionnumber) | |
Turns course section highlighting on. More... | |
i_unselect_category_in_the_management_interface ($name) | |
Clicks on a category checkbox in the management interface, if checked. More... | |
i_unselect_course_in_the_management_interface ($name) | |
Clicks course checkbox in the management interface, if checked. More... | |
i_wait_until_section_is_available ($sectionnumber) | |
Waits until the section is available to interact with it. More... | |
look_for_exceptions () | |
Internal step definition to find exceptions, debugging() messages and PHP debug messages. More... | |
normalise_selector (string $selector, $locator, Element $container) | |
Normalise the locator and selector. More... | |
section_activities_should_be_hidden ($sectionnumber) | |
Checks that all actiities in the specified section are hidden. More... | |
section_should_be_hidden ($sectionnumber) | |
Checks that the specified section is visible. More... | |
section_should_be_highlighted ($sectionnumber) | |
Checks if the specified course section hightlighting is turned on. More... | |
section_should_be_visible ($sectionnumber) | |
Checks that the specified section is visible. More... | |
section_should_not_be_highlighted ($sectionnumber) | |
Checks if the specified course section highlighting is turned off. 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... | |
get_activity_element ($element, $selectortype, $activityname) | |
Clicks on the specified element inside the activity container. More... | |
get_activity_name ($activitynode) | |
Gets the activity instance name from the activity node. More... | |
get_activity_node ($activityname) | |
Returns the DOM node of the activity from . More... | |
get_category_id ($idnumber) | |
Returns the id of the category with the given idnumber. More... | |
get_course_format () | |
Gets the current course format. More... | |
get_course_id ($idnumber) | |
Returns the id of the course with the given idnumber. More... | |
get_debug_text ($html) | |
Converts HTML tags to line breaks to display the info in CLI. More... | |
get_management_category_listing_node_by_idnumber ($idnumber) | |
Returns the category node from within the listing on the management page. More... | |
get_management_category_listing_node_by_name ($name, $link=false) | |
Returns a category node from within the management interface. More... | |
get_management_course_listing_node_by_idnumber ($idnumber) | |
Returns the course node from within the listing on the management page. More... | |
get_management_course_listing_node_by_name ($name, $link=false) | |
Returns a course node from within the management interface. More... | |
get_node_in_container ($selectortype, $element, $containerselectortype, $containerelement) | |
Gets the requested element inside the specified container. More... | |
get_section_activities ($sectionxpath) | |
Gets the section's activites DOM nodes. 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... | |
hide_section_link_exists ($sectionnumber) | |
Returns the hide section icon link if it exists or throws exception. More... | |
is_course_editor () | |
Returns whether the user can edit the course contents or not. More... | |
is_editing_on () | |
Returns whether the user can edit the course contents and the editing mode is on. More... | |
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... | |
listing_is_highlighted ($self, $selector) | |
Used by spin to determine the callback has been highlighted. More... | |
locate_path ($path) | |
Locates url, based on provided path. More... | |
require_javascript () | |
Require that javascript be available in the current Session. More... | |
resize_window ($windowsize, $viewport=false) | |
Change browser window size. 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... | |
section_exists ($sectionnumber) | |
Checks if the course section exists. More... | |
show_section_link_exists ($sectionnumber) | |
Returns the show section icon or throws an exception. More... | |
spin ($lambda, $args=false, $timeout=false, $exception=false, $microsleep=false) | |
Executes the passed closure until returns true or time outs. 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... | |
user_clicks_on_management_listing_action ($listingtype, $listingnode, $action) | |
Finds the node to use for a management listitem action and clicks it. More... | |
user_moves_listing_by_one ($listingtype, $listingnode, $direction, $highlight=true) | |
Moves a course or category listing within the management interface up or down by one. 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 |
|
inherited |
Checks that the specified activity's action menu is open.
@Then /^"(?P<activity_name_string>(?:[^"]|")*)" actions menu should be open$/
DriverException | The step is not available when Javascript is disabled |
string | $activityname |
|
inherited |
Checks that the specified activity's action menu contains an item.
@Then /^"(?P<activity_name_string>(?:[^"]|")*)" actions menu should have "(?P<menu_item_string>(?:[^"]|\")*)" item$/
DriverException | The step is not available when Javascript is disabled |
string | $activityname | |
string | $menuitem |
|
inherited |
Checks that the specified activity's action menu does not contains an item.
@Then /^"(?P<activity_name_string>(?:[^"]|")*)" actions menu should not have "(?P<menu_item_string>(?:[^"]|\")*)" item$/
DriverException | The step is not available when Javascript is disabled |
string | $activityname | |
string | $menuitem |
|
inherited |
Checks that the specified activity is visible.
You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
@Then /^"(?P<activity_or_resource_string>(?:[^"]|")*)" activity should be available but hidden from course page$/
string | $activityname |
ExpectationException |
|
inherited |
Checks that the specified activity is dimmed.
You need to be in the course page.
@Then /^"(?P<activity_or_resource_string>(?:[^"]|")*)" activity should be dimmed$/
string | $activityname |
ExpectationException |
|
inherited |
Checks that the specified activity is hidden.
You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
@Then /^"(?P<activity_or_resource_string>(?:[^"]|")*)" activity should be hidden$/
string | $activityname |
ExpectationException |
|
inherited |
Checks that the specified activity is visible.
You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
@Then /^"(?P<activity_or_resource_string>(?:[^"]|")*)" activity should be visible$/
string | $activityname |
ExpectationException |
|
inherited |
Checks that a category within the management interface is dimmed.
@Given /^category in management listing should be dimmed "(?P<idnumber_string>(?:[^"]|")*)"$/
string | $idnumber |
|
inherited |
Checks that a category within the management interface is visible.
@Given /^category in management listing should be visible "(?P<idnumber_string>(?:[^"]|")*)"$/
string | $idnumber |
|
inherited |
Checks that a course within the management interface is dimmed.
@Given /^course in management listing should be dimmed "(?P<idnumber_string>(?:[^"]|")*)"$/
string | $idnumber |
|
inherited |
Checks that a course within the management interface is visible.
@Given /^course in management listing should be visible "(?P<idnumber_string>(?:[^"]|")*)"$/
string | $idnumber |
|
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 |
|
protectedinherited |
Clicks on the specified element inside the activity container.
ElementNotFoundException |
string | $element | |
string | $selectortype | |
string | $activityname |
NodeElement |
|
protectedinherited |
Gets the activity instance name from the activity node.
ElementNotFoundException |
NodeElement | $activitynode |
string |
|
protectedinherited |
Returns the DOM node of the activity from .
ElementNotFoundException | Thrown by behat_base::find |
string | $activityname | The activity name |
NodeElement |
|
protectedinherited |
Returns the id of the category with the given idnumber.
Please note that this function requires the category to exist. If it does not exist an ExpectationException is thrown.
string | $idnumber |
string |
ExpectationException |
|
protectedinherited |
Gets the current course format.
ExpectationException | If we are not in the course view page. |
string | The course format in a frankenstyled name. |
|
protectedinherited |
Returns the id of the course with the given idnumber.
Please note that this function requires the category to exist. If it does not exist an ExpectationException is thrown.
string | $idnumber |
string |
ExpectationException |
|
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[] |
|
staticinherited |
Gets the extended timeout.
A longer timeout for cases where the normal timeout is not enough.
int | Timeout in seconds |
|
protectedinherited |
Returns the category node from within the listing on the management page.
string | $idnumber |
Behat |
|
protectedinherited |
Returns a category node from within the management interface.
string | $name | The name of the category. |
bool | $link | If set to true we'll resolve to the link rather than just the node. |
Behat |
|
protectedinherited |
Returns the course node from within the listing on the management page.
string | $idnumber |
Behat |
|
protectedinherited |
Returns a course node from within the management interface.
string | $name | The name of the course. |
bool | $link | If set to true we'll resolve to the link rather than just the node. |
Behat |
|
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.
|
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 |
|
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 the section's activites DOM nodes.
string | $sectionxpath |
array | NodeElement instances |
|
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 |
|
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 |
|
protectedinherited |
Returns the hide section icon link if it exists or throws exception.
ElementNotFoundException | Thrown by behat_base::find |
int | $sectionnumber |
NodeElement |
|
inherited |
Opens the activity chooser and opens the activity/resource form page.
Sections 0 and 1 are also allowed on frontpage.
@Given /^I add a "(?P<activity_or_resource_name_string>(?:[^"]|")*)" to section "(?P<section_number>\d+)"$/
ElementNotFoundException | Thrown by behat_base::find |
string | $activity | |
int | $section |
|
inherited |
Adds the selected activity/resource filling the form data with the specified field/value pairs.
Sections 0 and 1 are also allowed on frontpage.
@When /^I add a "(?P<activity_or_resource_name_string>(?:[^"]|")*)" to section "(?P<section_number>\d+)" and I fill the form with:$/
string | $activity | The activity name |
int | $section | The section number |
TableNode | $data | The activity field/value data |
|
inherited |
Edits the activity name through the edit activity; this step only works with Javascript enabled.
Editing mode should be on.
@Given /^I change "(?P<activity_name_string>(?:[^"]|")*)" activity name to "(?P<new_name_string>(?:[^"]|\")*)"$/
DriverException | Step not available when Javascript is disabled |
string | $activityname | |
string | $newactivityname |
|
inherited |
Locates a category in the course category management interface and then triggers an action for it.
@Given /^I click on "(?P<action_string>(?:[^"]|")*)" action for "(?P<name_string>(?:[^"]|\")*)" in management category listing$/
string | $action | The action to take. One of |
string | $name | The name of the category as it is displayed in the management interface. |
|
inherited |
Locates a course in the course category management interface and then triggers an action for it.
@Given /^I click on "(?P<action_string>(?:[^"]|")*)" action for "(?P<name_string>(?:[^"]|\")*)" in management course listing$/
string | $action | The action to take. One of |
string | $name | The name of the course as it is displayed in the management interface. |
|
inherited |
Clicks on a category in the management interface.
@Given /^I click on "(?P<categoryname_string>(?:[^"]|")*)" category in the management category listing$/
string | $name | The name of the category to click. |
|
inherited |
Clicks on a category in the management interface.
@Given /^I click on category "(?P<name_string>(?:[^"]|")*)" in the management interface$/
string | $name |
|
inherited |
Clicks on a course in the management interface.
@Given /^I click on course "(?P<name_string>(?:[^"]|")*)" in the management interface$/
string | $name |
|
inherited |
Clicks on the specified element of the activity.
You should be in the course page with editing mode turned on.
@Given /^I click on "(?P<element_string>(?:[^"]|")*)" "(?P<selector_string>(?:[^"]|\")*)" in the "(?P<activity_name_string>(?:[^"]|\")*)" activity$/
string | $element | |
string | $selectortype | |
string | $activityname |
|
inherited |
Click to expand a category revealing its sub categories within the management UI.
@Given /^I click to expand category "(?P<idnumber_string>(?:[^"]|")*)" in the management interface$/
string | $idnumber |
|
inherited |
Moves a category displayed in the management interface up or down one place.
@Given /^I click to move category "(?P<idnumber_string>(?:[^"]|")*)" (?P<direction>up|down) one$/
string | $idnumber | The category idnumber |
string | $direction | The direction to move in, either up or down |
|
inherited |
Moves a course displayed in the management interface up or down one place.
@Given /^I click to move course "(?P<idnumber_string>(?:[^"]|")*)" (?P<direction>up|down) one$/
string | $idnumber | The course idnumber |
string | $direction | The direction to move in, either up or down |
|
inherited |
Closes an activity actions menu if it is not already closed.
@Given /^I close "(?P<activity_name_string>(?:[^"]|")*)" actions menu$/
DriverException | The step is not available when Javascript is disabled |
string | $activityname |
|
inherited |
Creates a new course with the provided table data matching course settings names with the desired values.
@Given /^I create a course with:$/
TableNode | $table | The course data |
|
inherited |
Deletes the activity or resource specified by it's name.
This step is experimental when using it in Javascript tests. You should be in the course page with editing mode on.
@Given /^I delete "(?P<activity_name_string>(?:[^"]|")*)" activity$/
string | $activityname |
|
inherited |
Deletes course section.
@Given /^I delete section "(?P<section_number>\d+)"$/
int | $sectionnumber | The section number |
|
inherited |
Duplicates the activity or resource specified by it's name.
You should be in the course page with editing mode on.
@Given /^I duplicate "(?P<activity_name_string>(?:[^"]|")*)" activity$/
string | $activityname |
|
inherited |
Duplicates the activity or resource and modifies the new activity with the provided data.
You should be in the course page with editing mode on.
@Given /^I duplicate "(?P<activity_name_string>(?:[^"]|")*)" activity editing the new copy with:$/
string | $activityname | |
TableNode | $data |
|
inherited |
Go to editing section page for specified section number.
You need to be in the course page and on editing mode.
@Given /^I edit the section "(?P<section_number>\d+)"$/
int | $sectionnumber |
|
inherited |
Edit specified section and fill the form data with the specified field/value pairs.
@When /^I edit the section "(?P<section_number>\d+)" and I fill the form with:$/
int | $sectionnumber | The section number |
TableNode | $data | The activity field/value data |
|
inherited |
Goes to the system courses/categories management page.
@Given /^I go to the courses management page$/
|
inherited |
Hides the specified visible section.
You need to be in the course page and on editing mode.
@Given /^I hide section "(?P<section_number>\d+)"$/
int | $sectionnumber |
|
inherited |
Indents to the left the activity or resource specified by it's name.
Editing mode should be on.
@Given /^I indent left "(?P<activity_name_string>(?:[^"]|")*)" activity$/
string | $activityname |
|
inherited |
Indents to the right the activity or resource specified by it's name.
Editing mode should be on.
@Given /^I indent right "(?P<activity_name_string>(?:[^"]|")*)" activity$/
string | $activityname |
|
inherited |
Moves the specified activity to the first slot of a section.
This step is experimental when using it in Javascript tests. Editing mode should be on.
@Given /^I move "(?P<activity_name_string>(?:[^"]|")*)" activity to section "(?P<section_number>\d+)"$/
string | $activityname | The activity name |
int | $sectionnumber | The number of section |
|
inherited |
Move selected categories to top level in the management interface.
@Given /^I move category "(?P<name_string>(?:[^"]|")*)" to top level in the management interface$/
string | $name |
|
inherited |
Moves down the specified section, this step only works with Javascript disabled.
Editing mode should be on.
@Given /^I move down section "(?P<section_number>\d+)"$/
DriverException | Step not available when Javascript is enabled |
int | $sectionnumber |
|
inherited |
Moves up the specified section, this step only works with Javascript disabled.
Editing mode should be on.
@Given /^I move up section "(?P<section_number>\d+)"$/
DriverException | Step not available when Javascript is enabled |
int | $sectionnumber |
|
inherited |
Opens an activity actions menu if it is not already opened.
@Given /^I open "(?P<activity_name_string>(?:[^"]|")*)" actions menu$/
DriverException | The step is not available when Javascript is disabled |
string | $activityname |
|
inherited |
Opens a section edit menu if it is not already opened.
@Given /^I open section "(?P<section_number>\d+)" edit menu$/
DriverException | The step is not available when Javascript is disabled |
string | $sectionnumber |
|
inherited |
Clicks on a category checkbox in the management interface, if not checked.
@Given /^I select category "(?P<name_string>(?:[^"]|")*)" in the management interface$/
string | $name |
|
inherited |
Clicks course checkbox in the management interface, if not checked.
@Given /^I select course "(?P<name_string>(?:[^"]|")*)" in the management interface$/
string | $name |
|
inherited |
Checks that a category is not a subcategory of specific category.
@Given /^I should not see category "(?P<subcatidnumber_string>(?:[^"]|")*)" as subcategory of "(?P<catidnumber_string>(?:[^"]|\")*)" in the management interface$/
ExpectationException |
string | $subcatidnumber | |
string | $catidnumber |
|
inherited |
Check that one teacher oes not appears after another in the course contacts.
@Given /^I should not see teacher "(?P<fteacher_string>(?:[^"]|")*)" after "(?P<pteacher_string>(?:[^"]|\")*)" in the course contact listing$/
string | $fteacher | The teacher that should not be found (after the other teacher) |
string | $pteacher | The teacher after who the other should not be found (this teacher must be found!) |
ExpectationException |
|
inherited |
Checks that a category is a subcategory of specific category.
@Given /^I should see category "(?P<subcatidnumber_string>(?:[^"]|")*)" as subcategory of "(?P<catidnumber_string>(?:[^"]|\")*)" in the management interface$/
ExpectationException |
string | $subcatidnumber | |
string | $catidnumber |
|
inherited |
Check that one category appears before another in the course category management listings.
@Given /^I should see category listing "(?P<preceedingcategory_string>(?:[^"]|")*)" before "(?P<followingcategory_string>(?:[^"]|\")*)"$/
string | $preceedingcategory | The first category to find |
string | $followingcategory | The second category to find (should be after the first category) |
ExpectationException |
|
inherited |
Check that one course appears before another in the course category management listings.
@Given /^I should see course listing "(?P<preceedingcourse_string>(?:[^"]|")*)" before "(?P<followingcourse_string>(?:[^"]|\")*)"$/
string | $preceedingcourse | The first course to find |
string | $followingcourse | The second course to find (should be AFTER the first course) |
ExpectationException |
|
inherited |
Check that one teacher appears before another in the course contacts.
@Given /^I should see teacher "(?P<pteacher_string>(?:[^"]|")*)" before "(?P<fteacher_string>(?:[^"]|\")*)" in the course contact listing$/
string | $pteacher | The first teacher to find |
string | $fteacher | The second teacher to find (should be after the first teacher) |
ExpectationException |
|
inherited |
Checks that we are on the course management page that we expect to be on and that no course has been selected.
@Given /^I should see the "(?P<mode_string>(?:[^"]|")*)" management page$/
string | $mode | The mode to expected. One of 'Courses', 'Course categories' or 'Course categories and courses' |
|
inherited |
Checks that we are on the course management page that we expect to be on and that a course has been selected.
@Given /^I should see the "(?P<mode_string>(?:[^"]|")*)" management page with a course selected$/
string | $mode | The mode to expected. One of 'Courses', 'Course categories' or 'Course categories and courses' |
|
inherited |
Shows the specified hidden section.
You need to be in the course page and on editing mode.
@Given /^I show section "(?P<section_number>\d+)"$/
int | $sectionnumber |
|
inherited |
Clicks to expand or collapse a category displayed on the frontpage.
@Given /^I toggle "(?P<categoryname_string>(?:[^"]|")*)" category children visibility in frontpage$/
ExpectationException |
string | $categoryname |
|
inherited |
Toggles the visibility of a category in the management UI.
If it was visible it will be hidden. If it is hidden it will be made visible.
@Given /^I toggle visibility of category "(?P<idnumber_string>(?:[^"]|")*)" in management listing$/
|
inherited |
Toggles the visibility of a course in the management UI.
If it was visible it will be hidden. If it is hidden it will be made visible.
@Given /^I toggle visibility of course "(?P<idnumber_string>(?:[^"]|")*)" in management listing$/
string | $idnumber |
|
inherited |
Turns editing mode off.
@Given /^I turn editing mode off$/
|
inherited |
Turns editing mode on.
@Given /^I turn editing mode on$/
|
inherited |
Turns course section highlighting off.
@Given /^I turn section "(?P<section_number>\d+)" highlighting off$/
int | $sectionnumber | The section number |
|
inherited |
Turns course section highlighting on.
@Given /^I turn section "(?P<section_number>\d+)" highlighting on$/
int | $sectionnumber | The section number |
|
inherited |
Clicks on a category checkbox in the management interface, if checked.
@Given /^I unselect category "(?P<name_string>(?:[^"]|")*)" in the management interface$/
string | $name |
|
inherited |
Clicks course checkbox in the management interface, if checked.
@Given /^I unselect course "(?P<name_string>(?:[^"]|")*)" in the management interface$/
string | $name |
|
inherited |
Waits until the section is available to interact with it.
Useful when the section is performing an action and the section is overlayed with a loading layout.
Using the protected method as this method will be usually called by other methods which are not returning a set of steps and performs the actions directly, so it would not be executed if it returns another step.
Hopefully we would not require test writers to use this step and we will manage it from other step definitions.
@Given /^I wait until section "(?P<section_number>\d+)" is available$/
int | $sectionnumber |
void |
|
protectedinherited |
Returns whether the user can edit the course contents or not.
bool |
|
protectedinherited |
Returns whether the user can edit the course contents and the editing mode is on.
bool |
|
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 |
Used by spin to determine the callback has been highlighted.
behat_course | $self | A self reference (default first arg from a spin callback) |
Behat\Mink\Element\NodeElement | $selector |
bool |
|
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. |
|
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 |
|
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 |
|
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 |
|
inherited |
Checks that all actiities in the specified section are hidden.
You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
@Then /^all activities in section "(?P<section_number>\d+)" should be hidden$/
ExpectationException | |
ElementNotFoundException | Thrown by behat_base::find |
int | $sectionnumber |
|
protectedinherited |
Checks if the course section exists.
ElementNotFoundException | Thrown by behat_base::find |
int | $sectionnumber |
string | The xpath of the section. |
|
inherited |
Checks that the specified section is visible.
You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
@Then /^section "(?P<section_number>\d+)" should be hidden$/
ExpectationException | |
ElementNotFoundException | Thrown by behat_base::find |
int | $sectionnumber |
|
inherited |
Checks if the specified course section hightlighting is turned on.
You need to be in the course page on editing mode.
@Then /^section "(?P<section_number>\d+)" should be highlighted$/
ExpectationException |
int | $sectionnumber | The section number |
|
inherited |
Checks that the specified section is visible.
You need to be in the course page. It can be used being logged as a student and as a teacher on editing mode.
@Then /^section "(?P<section_number>\d+)" should be visible$/
ExpectationException |
int | $sectionnumber |
|
inherited |
Checks if the specified course section highlighting is turned off.
You need to be in the course page on editing mode.
@Then /^section "(?P<section_number>\d+)" should not be highlighted$/
ExpectationException |
int | $sectionnumber | The section number |
|
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 |
|
protectedinherited |
Returns the show section icon or throws an exception.
ElementNotFoundException | Thrown by behat_base::find |
int | $sectionnumber |
NodeElement |
|
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 |
|
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. |
|
protectedinherited |
Finds the node to use for a management listitem action and clicks it.
string | $listingtype | Either course or category. |
Behat\Mink\Element\NodeElement | $listingnode | |
string | $action | The action being taken |
Behat |
|
protectedinherited |
Moves a course or category listing within the management interface up or down by one.
string | $listingtype | One of course or category |
Behat\Mink\Element\NodeElement | $listingnode | |
string | $direction | One of up or down. |
bool | $highlight | If set to false we don't check the node has been highlighted. |
|
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...).