Moodle PHP Documentation 4.4
Moodle 4.4.1 (Build: 20240610) (db07c09afc5)
|
Public Member Functions | |
a_new_page_should_have_loaded_since_i_started_watching () | |
Verify that a new page has loaded (or the same page has reloaded) since the last "I start watching to see if a new page loads" step. | |
a_new_page_should_not_have_loaded_since_i_started_watching () | |
Verify that a new page has not loaded (or the same page has reloaded) since the last "I start watching to see if a new page loads" step. | |
accept_currently_displayed_alert_dialog () | |
Accepts the currently displayed alert dialog. | |
assert_element_contains_text ($text, $element, $selectortype) | |
Checks, that the specified element contains the specified text. | |
assert_element_not_contains_text ($text, $element, $selectortype) | |
Checks, that the specified element does not contain the specified text. | |
assert_page_contains_text ($text) | |
Checks, that page contains specified text. | |
assert_page_not_contains_text ($text) | |
Checks, that page doesn't contain specified text. | |
click_link ($link) | |
Clicks link with specified id|title|alt|text. | |
database_family_used_is_one_of_the_following (TableNode $databasefamilies) | |
Checks if database family used is using one of the specified, else skip. | |
dismiss_currently_displayed_alert_dialog () | |
Dismisses the currently displayed alert dialog. | |
download_file_from_link ($link) | |
Given the text of a link, download the linked file and return the contents. | |
edit_mode_should_be_available (bool $not=false) | |
Ensure that edit mode is (not) available on the current page. | |
following_should_download_between_and_bytes ($link, $minexpectedsize, $maxexpectedsize) | |
Downloads the file from a link on the page and checks the size is in a given range. | |
following_should_download_bytes ($link, $expectedsize) | |
Downloads the file from a link on the page and checks the size. | |
following_should_exist_in_the_table ($table, TableNode $data) | |
Checks that the provided value exist in table. | |
following_should_not_exist_in_the_table ($table, TableNode $data) | |
Checks that the provided values do not exist in a table. | |
getSession ($name=null) | |
Returns the Mink session. | |
i_am_on_course_index () | |
Opens course index page. | |
i_am_on_homepage () | |
Opens Moodle homepage. | |
i_am_on_site_homepage () | |
Opens Moodle site homepage. | |
i_change_window_size_to ($windowviewport, $windowsize) | |
Change browser window size. | |
i_click_on ($element, $selectortype) | |
Generic click action. | |
i_click_on_confirming_the_dialogue ($element, $selectortype) | |
Clicks the specified element and confirms the expected dialogue. | |
i_click_on_dismissing_the_dialogue ($element, $selectortype) | |
Clicks the specified element and dismissing the expected dialogue. | |
i_click_on_in_the ($element, $selectortype, $nodeelement, $nodeselectortype) | |
Click on the element of the specified type which is located inside the second element. | |
i_click_on_skipping_visibility_check ($element, $selectortype) | |
Trigger click on node via javascript instead of actually clicking on it via pointer. | |
i_click_on_the_dynamic_tab (string $tabname) | |
Click on a dynamic tab to load its content. | |
i_close_all_opened_windows () | |
Closes all extra windows opened during the navigation. | |
i_drag_and_i_drop_it_in ($source, $sourcetype, $target, $targettype) | |
Drags and drops the specified element to the specified container. | |
i_enable_plugin ($plugin, $plugintype) | |
Enable an specific plugin. | |
i_hover ($element, $selectortype) | |
Generic mouse over action. | |
i_hover_in_the (string $element, $selectortype, string $containerelement, $containerselectortype) | |
Generic mouse over action. | |
i_key_click_on_in_the ($modifier, $element, $selectortype, $nodeelement, $nodeselectortype) | |
Click on the element with some modifier key pressed (alt, shift, meta or control). | |
i_manually_press_enter () | |
Manually press enter key. | |
i_manually_press_tab ($shift='') | |
Manually press tab key. | |
i_mark_this_test_as_long_running (int $factor=2) | |
Increase the webdriver timeouts. | |
i_pause_scenario_execution () | |
Wait unit user press Enter/Return key. | |
i_post_tab_key_in_element ($element, $selectortype) | |
Press tab key on a specific element. | |
i_press_in_the_browser ($button) | |
Presses a given button in the browser. | |
i_press_key_in_element ($key, $element, $selectortype) | |
Trigger a keydown event for a key on a specific element. | |
i_press_named_key (string $modifiers, string $key) | |
Press a named or character key with an optional set of modifiers. | |
i_run_all_adhoc_tasks () | |
Runs all ad-hoc tasks in the queue. | |
i_run_the_scheduled_task ($taskname) | |
Runs a scheduled task immediately, given full class name. | |
i_should_see_node_occurrences_of_type_in_element (int $elementscount, string $nodetype, string $element, string $selectortype) | |
Checks, that the specified element contains the specified node type a certain amount of times. | |
i_should_see_occurrences_of_in_element ($elementscount, $text, $element, $selectortype) | |
Checks, that the specified element contains the specified text a certain amount of times. | |
i_start_watching_to_see_if_a_new_page_loads () | |
Prepare to detect whether or not a new page has loaded (or the same page reloaded) some time in the future. | |
i_take_focus_off_field ($element, $selectortype) | |
Sets the focus and takes away the focus from an element, generating blur JS event. | |
i_trigger_cron () | |
This step triggers cron like a user would do going to admin/cron.php. | |
i_type (string $keys) | |
Send key presses to the browser without first changing focusing, or applying the key presses to a specific element. | |
i_visit ($localurl) | |
Visit a local URL relative to the behat root. | |
i_wait_seconds ($seconds) | |
Waits X seconds. | |
i_wait_to_be_redirected () | |
Follows the page redirection. | |
in_the_should_be_visible ($element, $selectortype, $nodeelement, $nodeselectortype) | |
Checks, that the specified element is visible inside the specified container. | |
in_the_should_not_be_visible ($element, $selectortype, $nodeelement, $nodeselectortype) | |
Checks, that the existing element is not visible inside the existing container. | |
is_edit_mode_available () | |
Check whether edit mode is available on the current page. | |
plugin_is_installed (string $plugin) | |
Checks if given plugin is installed, and skips the current scenario if not. | |
reload () | |
Reloads the current page. | |
row_column_of_table_should_contain ($row, $column, $table, $value) | |
Checks the provided value exists in specific row/column of table. | |
row_column_of_table_should_not_contain ($row, $column, $table, $value) | |
Checks the provided value should not exist in specific row/column of table. | |
should_appear_after (string $postelement, string $postselectortype, string $preelement, string $preselectortype, ?string $containerelement=null, ?string $containerselectortype=null) | |
Checks, that the first specified element appears after the second one. | |
should_appear_before (string $preelement, string $preselectortype, string $postelement, string $postselectortype, ?string $containerelement=null, ?string $containerselectortype=null) | |
Checks, that the first specified element appears before the second one. | |
should_be_visible ($element, $selectortype) | |
Checks, that the specified element is visible. | |
should_exist ($element, $selectortype) | |
Checks the provided element and selector type exists in the current page. | |
should_exist_in_the ($element, $selectortype, $containerelement, $containerselectortype) | |
Checks that an element and selector type exists in another element and selector type on the current page. | |
should_not_be_visible ($element, $selectortype) | |
Checks, that the existing element is not visible. | |
should_not_exist ($element, $selectortype) | |
Checks that the provided element and selector type not exists in the current page. | |
should_not_exist_in_the ($element, $selectortype, $containerelement, $containerselectortype) | |
Checks that an element and selector type does not exist in another element and selector type on the current page. | |
switch_to_iframe ($name) | |
Switches to the specified iframe. | |
switch_to_second_window () | |
Switches to a second window. | |
switch_to_the_main_frame () | |
Switches to the main Moodle frame. | |
switch_to_the_main_window () | |
Switches to the main Moodle window. | |
switch_to_window ($windowname) | |
Switches to the specified window. | |
the_attribute_of_should_be_set ($attribute, $element, $selectortype, $not=null) | |
Checks whether there the specified attribute is set or not. | |
the_attribute_of_should_contain ($attribute, $element, $selectortype, $text) | |
Checks whether there is an attribute on the given element that contains the specified text. | |
the_attribute_of_should_not_contain ($attribute, $element, $selectortype, $text) | |
Checks that the attribute on the given element does not contain the specified text. | |
the_default_editor_is_set_to (string $editor) | |
Set the default text editor to the named text editor. | |
the_element_should_be_disabled ($element, $selectortype) | |
Checks, that element of specified type is disabled. | |
the_element_should_be_enabled ($element, $selectortype) | |
Checks, that element of specified type is enabled. | |
the_element_should_be_readonly ($element, $selectortype) | |
Checks the provided element and selector type are readonly on the current page. | |
the_element_should_not_be_readonly ($element, $selectortype) | |
Checks the provided element and selector type are not readonly on the current page. | |
the_focused_element_is ($not, $nodeelement, $nodeselectortype) | |
Checks focus is with the given element. | |
the_focused_element_is_in_the ($not, $element, $selectortype, $nodeelement, $nodeselectortype) | |
Checks focus is with the given element. | |
the_image_at_should_be_identical_to ($element, $selectortype, $filepath) | |
Checks that the image on the page is the same as one of the fixture files. | |
the_page_title_should_contain (string $title) | |
Check that the page title contains a given string. | |
the_site_is_running_moodle_version_or_higher (string $minversion) | |
Allow to check for minimal Moodle version. | |
the_site_is_running_moodle_version_or_lower (string $maxversion) | |
Allow to check for maximum Moodle version. | |
wait_until_does_not_exists ($element, $selectortype) | |
Waits until the provided element does not exist in the DOM. | |
wait_until_exists ($element, $selectortype) | |
Waits until the provided element selector exists in the DOM. | |
wait_until_the_page_is_ready () | |
Waits until the page is completely loaded. | |
Public Attributes | |
string const | MAIN_WINDOW_NAME = '__moodle_behat_main_window_name' |
used by switch_to_window() and switch_to_the_main_window() to work-around a Chrome browser issue. | |
string const | PAGE_LOAD_DETECTION_STRING = 'new_page_not_loaded_since_behat_started_watching' |
when we want to check whether or not a new page has loaded, we first write this unique string into the page. | |
const | PAGE_READY_JS |
The JS code to check that the page is ready. | |
Protected Member Functions | |
check_element_order (?string $containerelement, ?string $containerselectortype, string $preelement, string $preselectortype, string $postelement, string $postselectortype, string $msg) | |
Shared code to check whether an element is before or after another one. | |
get_page_load_xpath () | |
Helper used by a_new_page_should_have_loaded_since_i_started_watching and a_new_page_should_not_have_loaded_since_i_started_watching. | |
|
inherited |
Verify that a new page has loaded (or the same page has reloaded) since the last "I start watching to see if a new page loads" step.
@Given /^a new page should have loaded since I started watching$/
|
inherited |
Verify that a new page has not loaded (or the same page has reloaded) since the last "I start watching to see if a new page loads" step.
@Given /^a new page should not have loaded since I started watching$/
|
inherited |
Accepts the currently displayed alert dialog.
This step does not work in all the browsers, consider it experimental. @Given /^I accept the currently displayed dialog$/
|
inherited |
Checks, that the specified element contains the specified text.
When running Javascript tests it also considers that texts may be hidden.
@Then /^I should see "(?P<text_string>(?:[^"]|::")*)" in the "(?P<element_string>(?:[^"]|")*)" "(?P<text_selector_string>[^"]*)"$/
ElementNotFoundException | |
ExpectationException |
string | $text | |
string | $element | Element we look in. |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Checks, that the specified element does not contain the specified text.
When running Javascript tests it also considers that texts may be hidden.
@Then /^I should not see "(?P<text_string>(?:[^"]|::")*)" in the "(?P<element_string>(?:[^"]|")*)" "(?P<text_selector_string>[^"]*)"$/
ElementNotFoundException | |
ExpectationException |
string | $text | |
string | $element | Element we look in. |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Checks, that page contains specified text.
It also checks if the text is visible when running Javascript tests.
@Then /^I should see "(?P<text_string>(?:[^"]|::")*)"$/
ExpectationException |
string | $text |
|
inherited |
Checks, that page doesn't contain specified text.
When running Javascript tests it also considers that texts may be hidden.
@Then /^I should not see "(?P<text_string>(?:[^"]|::")*)"$/
ExpectationException |
string | $text |
|
protectedinherited |
Shared code to check whether an element is before or after another one.
string | $containerelement | |
string | $containerselectortype | |
string | $preelement | The locator of the preceding element |
string | $preselectortype | The locator of the preceding element |
string | $postelement | The locator of the following element |
string | $postselectortype | The selector type of the following element |
string | $msg | Message to output if this fails |
|
inherited |
Clicks link with specified id|title|alt|text.
@When /^I follow "(?P<link_string>(?:[^"]|::")*)"$/
ElementNotFoundException | Thrown by behat_base\find |
string | $link |
|
inherited |
Checks if database family used is using one of the specified, else skip.
(mysql, postgres, mssql, oracle, etc.)
@Given /^database family used is one of the following:$/
TableNode | $databasefamilies | list of database. |
void. |
|
inherited |
Dismisses the currently displayed alert dialog.
This step does not work in all the browsers, consider it experimental. @Given /^I dismiss the currently displayed dialog$/
|
inherited |
Given the text of a link, download the linked file and return the contents.
This is a helper method used by following_should_download_bytes() and following_should_download_between_and_bytes()
string | $link | the text of the link. |
string | the content of the downloaded file. |
|
inherited |
Ensure that edit mode is (not) available on the current page.
@Then edit mode should be available on the current page @Then edit mode should :not be available on the current page
bool | $not |
|
inherited |
Downloads the file from a link on the page and checks the size is in a given range.
Only works if the link has an href attribute. Javascript downloads are not supported. Currently, the href must be an absolute URL.
The range includes the endpoints. That is, a 10 byte file in considered to be between "5" and "10" bytes, and between "10" and "20" bytes.
@Then /^following "(?P<link_string>[^"]*)" should download between "(?P<min_bytes>\d+)" and "(?P<max_bytes>\d+)" bytes$/
ExpectationException |
string | $link | the text of the link. |
number | $minexpectedsize | the minimum expected file size in bytes. |
number | $maxexpectedsize | the maximum expected file size in bytes. |
|
inherited |
Downloads the file from a link on the page and checks the size.
Only works if the link has an href attribute. Javascript downloads are not supported. Currently, the href must be an absolute URL.
@Then /^following "(?P<link_string>[^"]*)" should download "(?P<expected_bytes>\d+)" bytes$/
ExpectationException |
string | $link | the text of the link. |
number | $expectedsize | the expected file size in bytes. |
|
inherited |
Checks that the provided value exist in table.
First row may contain column headers or numeric indexes of the columns (syntax -1- is also considered to be column index). Column indexes are useful in case of multirow headers and/or presence of cells with colspan.
@Then /^the following should exist in the "(?P<table_string>[^"]*)" table:$/
ExpectationException |
string | $table | name of table |
TableNode | $data | table with first row as header and following values | Header 1 | Header 2 | Header 3 | | Value 1 | Value 2 | Value 3| |
|
inherited |
Checks that the provided values do not exist in a table.
@Then /^the following should not exist in the "(?P<table_string>[^"]*)" table:$/
ExpectationException |
string | $table | name of table |
TableNode | $data | table with first row as header and following values | Header 1 | Header 2 | Header 3 | | Value 1 | Value 2 | Value 3| |
|
protectedinherited |
Helper used by a_new_page_should_have_loaded_since_i_started_watching and a_new_page_should_not_have_loaded_since_i_started_watching.
string | xpath expression. |
|
inherited |
Returns the Mink session.
string | null | $name | name of the session OR active session will be used |
Behat\Mink\Session |
Implemented in behat_form_field.
|
inherited |
Opens course index page.
@Given /^I am on course index$/
|
inherited |
Opens Moodle homepage.
@Given /^I am on homepage$/
|
inherited |
Opens Moodle site homepage.
@Given /^I am on site homepage$/
|
inherited |
Change browser window size.
Allowed sizes:
Example: I change window size to "small" or I change window size to "1024x768" or I change viewport size to "800x600". The viewport option is useful to guarantee that the browser window has same viewport size even when you run Behat on multiple operating systems.
ExpectationException | @Then /^I change (window|viewport) size to "(mobile|tablet|small|medium|large|d+x::d+)"$/ @Then /^I change the (window|viewport) size to "(mobile|tablet|small|medium|large|d+x::d+)"$/ |
string | $windowsize | size of the window (mobile|tablet|small|medium|large|wxh). |
|
inherited |
Generic click action.
Click on the element of the specified type.
@When /^I click on "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)"$/
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
|
inherited |
Clicks the specified element and confirms the expected dialogue.
@When /^I click on "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" confirming the dialogue$/
ElementNotFoundException | Thrown by behat_base\find |
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
|
inherited |
Clicks the specified element and dismissing the expected dialogue.
@When /^I click on "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" dismissing the dialogue$/
ElementNotFoundException | Thrown by behat_base\find |
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
|
inherited |
Click on the element of the specified type which is located inside the second element.
@When /^I click on "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" in the "(?P<element_container_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)"$/
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
string | $nodeelement | Element we look in |
string | $nodeselectortype | The type of selector where we look in |
|
inherited |
Trigger click on node via javascript instead of actually clicking on it via pointer.
This function resolves the issue of nested elements.
@When /^I click on "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" skipping visibility check$/
string | $element | |
string | $selectortype |
|
inherited |
Click on a dynamic tab to load its content.
@Given /^I click on the "(?P<tab_string>(?:[^"]|::")*)" dynamic tab$/
string | $tabname |
|
inherited |
Closes all extra windows opened during the navigation.
This assumes all popups are opened by the main tab and you will now get back.
@Given /^I close all opened windows$/
DriverException | If there aren't exactly 1 tabs open when finish or no javascript running |
|
inherited |
Drags and drops the specified element to the specified container.
This step does not work in all the browsers, consider it experimental.
The steps definitions calling this step as part of them should manage the wait times by themselves as the times and when the waits should be done depends on what is being dragged & dropper.
@Given /^I drag "(?P<element_string>(?:[^"]|::")*)" "(?P<selector1_string>(?:[^"]|")*)" and I drop it in "(?P<container_element_string>(?:[^"]|::")*)" "(?P<selector2_string>(?:[^"]|\")*)"$/
string | $element | |
string | $selectortype | |
string | $containerelement | |
string | $containerselectortype |
|
inherited |
Enable an specific plugin.
@When /^I enable "(?P<plugin_string>(?:[^"]|::")*)" "(?P<plugintype_string>[^"]*)" plugin$/
string | $plugin | Plugin we look for |
string | $plugintype | The type of the plugin |
|
inherited |
Generic mouse over action.
Mouse over a element of the specified type.
@When /^I hover "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)"$/
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
|
inherited |
Generic mouse over action.
Mouse over a element of the specified type.
@When I hover over the :element :selectortype in the :containerelement :containerselectortype
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
string | $containerelement | Element we look for |
string | $containerselectortype | The type of what we look for |
|
inherited |
Click on the element with some modifier key pressed (alt, shift, meta or control).
It is important to note that not all HTML elements are compatible with this step because the webdriver limitations. For example, alt click on checkboxes with a visible label will produce a normal checkbox click without the modifier.
@When I :modifier click on :element :selectortype in the :nodeelement :nodeselectortype
string | $modifier | the extra modifier to press (for example, alt+shift or shift) |
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
string | $nodeelement | Element we look in |
string | $nodeselectortype | The type of selector where we look in |
|
inherited |
Manually press enter key.
@When /^I press enter/
DriverException |
|
inherited |
Manually press tab key.
@When /^I press( shift)? tab$/
string | $shift | string optional step verifier |
DriverException |
|
inherited |
Increase the webdriver timeouts.
This should be reset between scenarios, or can be called again to decrease the timeouts.
@Given I mark this test as slow setting a timeout factor of :factor
|
inherited |
Wait unit user press Enter/Return key.
Useful when debugging a scenario.
@Then /^(?:|I )pause(?:| scenario execution)$/
|
inherited |
Press tab key on a specific element.
@When /^I press tab key in "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)"$/
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
DriverException | |
ExpectationException |
|
inherited |
Presses a given button in the browser.
NOTE: Phantomjs and browserkit driver reloads page while navigating back and forward.
@Then /^I press the "(back|forward|reload)" button in the browser$/
string | $button | the button to press. |
ExpectationException |
|
inherited |
Trigger a keydown event for a key on a specific element.
@When /^I press key "(?P<key_string>(?:[^"]|::")*)" in "(?P<element_string>(?:[^"]|")*)" "(?P<selector_string>[^"]*)"$/
string | $key | either char-code or character itself, may optionally be prefixed with ctrl-, alt-, shift- or meta- |
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
DriverException | |
ExpectationException |
|
inherited |
Press a named or character key with an optional set of modifiers.
Supported named keys are:
You can also use a single character for the key name e.g. 'Ctrl C'.
Supported moderators are:
Example usage of this new step: When I press the up key When I press the space key When I press the shift tab key
Multiple moderator keys can be combined using the '+' operator, for example: When I press the ctrl+shift enter key When I press the ctrl + shift enter key
@When /^I press the (?P<modifiers_string>.* )?(?P<key_string>.*) key$/
string | $modifiers | A list of keyboard modifiers, separated by the + character |
string | $key | The name of the key to press |
|
inherited |
Runs all ad-hoc tasks in the queue.
This is faster and more reliable than running cron (running cron won't work more than once in the same test, for instance). However it is a little less 'realistic'.
While the task is running, we suppress mtrace output because it makes the Behat result look ugly.
@Given /^I run all adhoc tasks$/
DriverException |
|
inherited |
Runs a scheduled task immediately, given full class name.
This is faster and more reliable than running cron (running cron won't work more than once in the same test, for instance). However it is a little less 'realistic'.
While the task is running, we suppress mtrace output because it makes the Behat result look ugly.
Note: Most of the code relating to running a task is based on admin/cli/scheduled_task.php.
@Given /^I run the scheduled task "(?P<task_name>[^"]+)"$/
string | $taskname | Name of task e.g. 'mod_whatever\task\do_something' |
|
inherited |
Checks, that the specified element contains the specified node type a certain amount of times.
When running Javascript tests it also considers that texts may be hidden.
@Then /^I should see "(?P<elementscount_number>::d+)" node occurrences of type "(?P<node_type>(?:[^"]|")*)" in the "(?P<element_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)"$/
ElementNotFoundException | |
ExpectationException |
int | $elementscount | How many occurrences of the element we look for. |
string | $nodetype | |
string | $element | Element we look in. |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Checks, that the specified element contains the specified text a certain amount of times.
When running Javascript tests it also considers that texts may be hidden.
@Then /^I should see "(?P<elementscount_number>::d+)" occurrences of "(?P<text_string>(?:[^"]|")*)" in the "(?P<element_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)"$/
ElementNotFoundException | |
ExpectationException |
int | $elementscount | How many occurrences of the element we look for. |
string | $text | |
string | $element | Element we look in. |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Prepare to detect whether or not a new page has loaded (or the same page reloaded) some time in the future.
@Given /^I start watching to see if a new page loads$/
|
inherited |
Sets the focus and takes away the focus from an element, generating blur JS event.
@When /^I take focus off "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)"$/
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
|
inherited |
This step triggers cron like a user would do going to admin/cron.php.
@Given /^I trigger cron$/
|
inherited |
Send key presses to the browser without first changing focusing, or applying the key presses to a specific element.
Example usage of this step: When I type "Penguin"
@When I type :keys
string | $keys | The key, or list of keys, to type |
|
inherited |
Visit a local URL relative to the behat root.
@When I visit :localurl
string | moodle_url | $localurl | The URL relative to the behat_wwwroot to visit. |
|
inherited |
Waits X seconds.
Required after an action that requires data from an AJAX request.
@Then /^I wait "(?P<seconds_number>::d+)" seconds$/
int | $seconds |
|
inherited |
Follows the page redirection.
Use this step after any action that shows a message and waits for a redirection
@Given /^I wait to be redirected$/
|
inherited |
Checks, that the specified element is visible inside the specified container.
Only available in tests using Javascript.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" in the "(?P<element_container_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)" should be visible$/
ElementNotFoundException | |
DriverException | |
ExpectationException |
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
string | $nodeelement | Element we look in |
string | $nodeselectortype | The type of selector where we look in |
|
inherited |
Checks, that the existing element is not visible inside the existing container.
Only available in tests using Javascript.
As a "not" method, it's performance could not be good, but in this case the performance is good because the element must exist, otherwise there would be a ElementNotFoundException, also here we are not spinning until the element is visible.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" in the "(?P<element_container_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)" should not be visible$/
ElementNotFoundException | |
ExpectationException |
string | $element | Element we look for |
string | $selectortype | The type of what we look for |
string | $nodeelement | Element we look in |
string | $nodeselectortype | The type of selector where we look in |
behat_theme_classic_behat_general::is_edit_mode_available | ( | ) |
Check whether edit mode is available on the current page.
bool |
Reimplemented from behat_general.
|
inherited |
Checks if given plugin is installed, and skips the current scenario if not.
@Given the :plugin plugin is installed
string | $plugin | frankenstyle plugin name, e.g. 'filter_embedquestion'. |
|
inherited |
Reloads the current page.
@Given /^I reload the page$/
|
inherited |
Checks the provided value exists in specific row/column of table.
@Then /^"(?P<row_string>[^"]*)" row "(?P<column_string>[^"]*)" column of "(?P<table_string>[^"]*)" table should contain "(?P<value_string>[^"]*)"$/
ElementNotFoundException |
string | $row | row text which will be looked in. |
string | $column | column text to search (or numeric value for the column position) |
string | $table | table id/class/caption |
string | $value | text to check. |
|
inherited |
Checks the provided value should not exist in specific row/column of table.
@Then /^"(?P<row_string>[^"]*)" row "(?P<column_string>[^"]*)" column of "(?P<table_string>[^"]*)" table should not contain "(?P<value_string>[^"]*)"$/
ElementNotFoundException |
string | $row | row text which will be looked in. |
string | $column | column text to search |
string | $table | table id/class/caption |
string | $value | text to check. |
|
inherited |
Checks, that the first specified element appears after the second one.
@Then :postelement :postselectortype should appear after :preelement :preselectortype @Then :postelement :postselectortype should appear after :preelement :preselectortype in the :containerelement :containerselectortype
ExpectationException |
string | $postelement | The locator of the latest element |
string | $postselectortype | The selector type of the latest element |
string | $preelement | The locator of the preceding element |
string | $preselectortype | The selector type of the preceding element |
string | $containerelement | |
string | $containerselectortype |
|
inherited |
Checks, that the first specified element appears before the second one.
@Then :preelement :preselectortype should appear before :postelement :postselectortype @Then :preelement :preselectortype should appear before :postelement :postselectortype in the :containerelement :containerselectortype
ExpectationException |
string | $preelement | The locator of the preceding element |
string | $preselectortype | The selector type of the preceding element |
string | $postelement | The locator of the latest element |
string | $postselectortype | The selector type of the latest element |
string | $containerelement | |
string | $containerselectortype |
|
inherited |
Checks, that the specified element is visible.
Only available in tests using Javascript.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>(?:[^"]|")*)" should be visible$/
ElementNotFoundException | |
ExpectationException | |
DriverException |
string | $element | |
string | $selectortype |
void |
|
inherited |
Checks the provided element and selector type exists in the current page.
This step is for advanced users, use it if you don't find anything else suitable for what you need.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should exist$/
ElementNotFoundException | Thrown by behat_base\find |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
|
inherited |
Checks that an element and selector type exists in another element and selector type on the current page.
This step is for advanced users, use it if you don't find anything else suitable for what you need.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should exist in the "(?P<element2_string>(?:[^"]|::")*)" "(?P<selector2_string>[^"]*)"$/
ElementNotFoundException | Thrown by behat_base\find |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
NodeElement | string | $containerelement | The locator of the container selector |
string | $containerselectortype | The container selector type |
|
inherited |
Checks, that the existing element is not visible.
Only available in tests using Javascript.
As a "not" method, it's performance could not be good, but in this case the performance is good because the element must exist, otherwise there would be a ElementNotFoundException, also here we are not spinning until the element is visible.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>(?:[^"]|")*)" should not be visible$/
ElementNotFoundException | |
ExpectationException |
string | $element | |
string | $selectortype |
void |
|
inherited |
Checks that the provided element and selector type not exists in the current page.
This step is for advanced users, use it if you don't find anything else suitable for what you need.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should not exist$/
ExpectationException |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
|
inherited |
Checks that an element and selector type does not exist in another element and selector type on the current page.
This step is for advanced users, use it if you don't find anything else suitable for what you need.
@Then /^"(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should not exist in the "(?P<element2_string>(?:[^"]|::")*)" "(?P<selector2_string>[^"]*)"$/
ExpectationException |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
NodeElement | string | $containerelement | The locator of the container selector |
string | $containerselectortype | The container selector type |
|
inherited |
Switches to the specified iframe.
@Given /^I switch to "(?P<iframe_name_string>(?:[^"]|::")*)" iframe$/ @Given /^I switch to "(?P<iframe_name_string>(?:[^"]|::")*)" class iframe$/
string | $name | The name of the iframe |
|
inherited |
Switches to a second window.
@Given /^I switch to a second window$/
DriverException | If there aren't exactly 2 windows open. |
|
inherited |
Switches to the main Moodle frame.
@Given /^I switch to the main frame$/
|
inherited |
Switches to the main Moodle window.
Useful when you finish interacting with popup windows.
@Given /^I switch to the main (window|tab)$/
|
inherited |
Switches to the specified window.
Useful when interacting with popup windows.
@Given /^I switch to "(?P<window_name_string>(?:[^"]|::")*)" (window|tab)$/
string | $windowname |
|
inherited |
Checks whether there the specified attribute is set or not.
@Then the :attribute attribute of :element :selectortype should be set @Then the :attribute attribute of :element :selectortype should :not be set
ExpectationException |
string | $attribute | Name of attribute |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
string | $not |
|
inherited |
Checks whether there is an attribute on the given element that contains the specified text.
@Then /^the "(?P<attribute_string>[^"]*)" attribute of "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should contain "(?P<text_string>(?:[^"]|::")*)"$/
ExpectationException |
string | $attribute | Name of attribute |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
string | $text | Expected substring |
|
inherited |
Checks that the attribute on the given element does not contain the specified text.
@Then /^the "(?P<attribute_string>[^"]*)" attribute of "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should not contain "(?P<text_string>(?:[^"]|::")*)"$/
ExpectationException |
string | $attribute | Name of attribute |
string | $element | The locator of the specified selector |
string | $selectortype | The selector type |
string | $text | Expected substring |
|
inherited |
Set the default text editor to the named text editor.
@Given the default editor is set to :editor
string | $editor |
ExpectationException | If the specified editor is not available. |
|
inherited |
Checks, that element of specified type is disabled.
@Then /^the "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should be disabled$/
ExpectationException | Thrown by behat_base\find |
string | $element | Element we look in |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Checks, that element of specified type is enabled.
@Then /^the "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should be enabled$/
ExpectationException | Thrown by behat_base\find |
string | $element | Element we look on |
string | $selectortype | The type of where we look |
|
inherited |
Checks the provided element and selector type are readonly on the current page.
@Then /^the "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should be readonly$/
ExpectationException | Thrown by behat_base\find |
string | $element | Element we look in |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Checks the provided element and selector type are not readonly on the current page.
@Then /^the "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should not be readonly$/
ExpectationException | Thrown by behat_base\find |
string | $element | Element we look in |
string | $selectortype | The type of element where we are looking in. |
|
inherited |
Checks focus is with the given element.
@Then /^the focused element is( not)? "(?P<node_string>(?:[^"]|::")*)" "(?P<node_selector_string>[^"]*)"$/
string | $not | optional step verifier |
string | $nodeelement | Element identifier |
string | $nodeselectortype | Element type |
DriverException | If not using JavaScript |
ExpectationException |
|
inherited |
Checks focus is with the given element.
@Then /^the focused element is( not)? "(?P<n>(?:[^"]|::")*)" "(?P<ns>[^"]*)" in the "(?P<c>(?:[^"]|::")*)" "(?P<cs>[^"]*)"$/
string | $not | string optional step verifier |
string | $element | Element identifier |
string | $selectortype | Element type |
string | $nodeelement | Element we look in |
string | $nodeselectortype | The type of selector where we look in |
DriverException | If not using JavaScript |
ExpectationException |
|
inherited |
Checks that the image on the page is the same as one of the fixture files.
@Then /^the image at "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" should be identical to "(?P<filepath_string>(?:[^"]|::")*)"$/
ExpectationException |
string | $element | The locator of the image |
string | $selectortype | The selector type |
string | $filepath | path to the fixture file |
|
inherited |
Check that the page title contains a given string.
@Given the page title should contain ":title"
string | $title | The string that should be present on the page title. |
|
inherited |
|
inherited |
|
inherited |
Waits until the provided element does not exist in the DOM.
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.
@Given /^I wait until "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" does not exist$/
string | $element | |
string | $selector |
void |
|
inherited |
Waits until the provided element selector exists in the DOM.
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.
@Given /^I wait until "(?P<element_string>(?:[^"]|::")*)" "(?P<selector_string>[^"]*)" exists$/
string | $element | |
string | $selector |
void |
|
inherited |
Waits until the page is completely loaded.
This step is auto-executed after every step.
@Given /^I wait until the page is ready$/
|
inherited |
when we want to check whether or not a new page has loaded, we first write this unique string into the page.
Then later, by checking whether it is still there, we can tell if a new page has been loaded.
|
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.