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... | |
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. More... | |
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. More... | |
accept_currently_displayed_alert_dialog () | |
Accepts the currently displayed alert dialog. More... | |
assert_element_contains_text ($text, $element, $selectortype) | |
Checks, that the specified element contains the specified text. More... | |
assert_element_not_contains_text ($text, $element, $selectortype) | |
Checks, that the specified element does not contain the specified text. More... | |
assert_page_contains_text ($text) | |
Checks, that page contains specified text. More... | |
assert_page_not_contains_text ($text) | |
Checks, that page doesn't contain specified text. More... | |
click_link ($link) | |
Clicks link with specified id|title|alt|text. More... | |
database_family_used_is_one_of_the_following (TableNode $databasefamilies) | |
Checks if database family used is using one of the specified, else skip. More... | |
dismiss_currently_displayed_alert_dialog () | |
Dismisses the currently displayed alert dialog. More... | |
download_file_from_link ($link) | |
Given the text of a link, download the linked file and return the contents. 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... | |
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. More... | |
following_should_download_bytes ($link, $expectedsize) | |
Downloads the file from a link on the page and checks the size. More... | |
following_should_exist_in_the_table ($table, TableNode $data) | |
Checks that the provided value exist in table. More... | |
following_should_not_exist_in_the_table ($table, TableNode $data) | |
Checks that the provided values do not exist in a table. More... | |
get_sesskey () | |
Get the session key for the current session via Javascript. More... | |
has_tag (string $tag) | |
Checks if the current scenario, or its feature, has a specified tag. More... | |
i_am_on_course_index () | |
Opens course index page. More... | |
i_am_on_homepage () | |
Opens Moodle homepage. More... | |
i_am_on_site_homepage () | |
Opens Moodle site homepage. More... | |
i_change_window_size_to ($windowviewport, $windowsize) | |
Change browser window size small: 640x480, medium: 1024x768, large: 2560x1600, custom: widthxheight. More... | |
i_click_on ($element, $selectortype) | |
Generic click action. More... | |
i_click_on_confirming_the_dialogue ($element, $selectortype) | |
Clicks the specified element and confirms the expected dialogue. More... | |
i_click_on_dismissing_the_dialogue ($element, $selectortype) | |
Clicks the specified element and dismissing the expected dialogue. More... | |
i_click_on_in_the ($element, $selectortype, $nodeelement, $nodeselectortype) | |
Click on the element of the specified type which is located inside the second element. More... | |
i_click_on_skipping_visibility_check ($element, $selectortype) | |
Trigger click on node via javascript instead of actually clicking on it via pointer. More... | |
i_drag_and_i_drop_it_in ($source, $sourcetype, $target, $targettype) | |
Drags and drops the specified element to the specified container. More... | |
i_hover ($element, $selectortype) | |
Generic mouse over action. More... | |
i_manually_press_tab ($shift='') | |
Manually press tab key. More... | |
i_pause_scenario_execution () | |
Wait unit user press Enter/Return key. More... | |
i_post_tab_key_in_element ($element, $selectortype) | |
Press tab key on a specific element. More... | |
i_press_in_the_browser ($button) | |
Presses a given button in the browser. More... | |
i_press_key_in_element ($key, $element, $selectortype) | |
Trigger a keydown event for a key on a specific element. More... | |
i_run_all_adhoc_tasks () | |
Runs all ad-hoc tasks in the queue. More... | |
i_run_the_scheduled_task ($taskname) | |
Runs a scheduled task immediately, given full class name. More... | |
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. More... | |
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. More... | |
i_take_focus_off_field ($element, $selectortype) | |
Sets the focus and takes away the focus from an element, generating blur JS event. More... | |
i_trigger_cron () | |
This step triggers cron like a user would do going to admin/cron.php. More... | |
i_visit ($localurl) | |
Visit a local URL relative to the behat root. More... | |
i_wait_seconds ($seconds) | |
Waits X seconds. More... | |
i_wait_to_be_redirected () | |
Follows the page redirection. More... | |
in_the_should_be_visible ($element, $selectortype, $nodeelement, $nodeselectortype) | |
Checks, that the specified element is visible inside the specified container. More... | |
in_the_should_not_be_visible ($element, $selectortype, $nodeelement, $nodeselectortype) | |
Checks, that the existing element is not visible inside the existing container. 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... | |
reload () | |
Reloads the current page. More... | |
row_column_of_table_should_contain ($row, $column, $table, $value) | |
Checks the provided value exists in specific row/column of table. More... | |
row_column_of_table_should_not_contain ($row, $column, $table, $value) | |
Checks the provided value should not exist in specific row/column of table. More... | |
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. More... | |
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. More... | |
should_be_visible ($element, $selectortype) | |
Checks, that the specified element is visible. More... | |
should_exist ($element, $selectortype) | |
Checks the provided element and selector type exists in the current page. More... | |
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. More... | |
should_not_be_visible ($element, $selectortype) | |
Checks, that the existing element is not visible. More... | |
should_not_exist ($element, $selectortype) | |
Checks that the provided element and selector type not exists in the current page. More... | |
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. More... | |
switch_to_class_iframe ($classname) | |
Switches to the iframe containing specified class. More... | |
switch_to_iframe ($iframename) | |
Switches to the specified iframe. More... | |
switch_to_the_main_frame () | |
Switches to the main Moodle frame. More... | |
switch_to_the_main_window () | |
Switches to the main Moodle window. More... | |
switch_to_window ($windowname) | |
Switches to the specified window. More... | |
the_attribute_of_should_contain ($attribute, $element, $selectortype, $text) | |
Checks whether there is an attribute on the given element that contains the specified text. More... | |
the_attribute_of_should_not_contain ($attribute, $element, $selectortype, $text) | |
Checks that the attribute on the given element does not contain the specified text. More... | |
the_element_should_be_disabled ($element, $selectortype) | |
Checks, that element of specified type is disabled. More... | |
the_element_should_be_enabled ($element, $selectortype) | |
Checks, that element of specified type is enabled. More... | |
the_element_should_be_readonly ($element, $selectortype) | |
Checks the provided element and selector type are readonly on the current page. More... | |
the_element_should_not_be_readonly ($element, $selectortype) | |
Checks the provided element and selector type are not readonly on the current page. More... | |
the_focused_element_is ($not, $nodeelement, $nodeselectortype) | |
Checks focus is with the given element. More... | |
the_focused_element_is_in_the ($not, $element, $selectortype, $nodeelement, $nodeselectortype) | |
Checks focus is with the given element. More... | |
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. More... | |
wait_for_pending_js () | |
Waits for all the JS to be loaded. More... | |
wait_until_does_not_exists ($element, $selectortype) | |
Waits until the provided element does not exist in the DOM. More... | |
wait_until_exists ($element, $selectortype) | |
Waits until the provided element selector exists in the DOM. More... | |
wait_until_the_page_is_ready () | |
Waits until the page is completely 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... | |
string const | MAIN_WINDOW_NAME = '__moodle_behat_main_window_name' |
used by } 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. 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 | |
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. More... | |
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_debug_text ($html) | |
Converts HTML tags to line breaks to display the info in CLI. More... | |
get_node_in_container ($selectortype, $element, $containerselectortype, $containerelement) | |
Gets the requested element inside the specified container. More... | |
get_page_load_xpath () | |
Helper used by } * and a_new_page_should_not_have_loaded_since_i_started_watching. 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... | |
is_in_app () | |
Checks if the current page is part of the mobile app. More... | |
js_trigger_click ($node) | |
Trigger click on node via javascript instead of actually clicking on it via pointer. More... | |
locate_path ($path) | |
Locates url, based on provided path. More... | |
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... | |
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... | |
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 |
behat_general::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.
@Given /^a new page should have loaded since I started watching$/
behat_general::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.
@Given /^a new page should not have loaded since I started watching$/
behat_general::accept_currently_displayed_alert_dialog | ( | ) |
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$/
behat_general::assert_element_contains_text | ( | $text, | |
$element, | |||
$selectortype | |||
) |
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. |
behat_general::assert_element_not_contains_text | ( | $text, | |
$element, | |||
$selectortype | |||
) |
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. |
behat_general::assert_page_contains_text | ( | $text | ) |
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 |
behat_general::assert_page_not_contains_text | ( | $text | ) |
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 |
|
protected |
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 |
behat_general::click_link | ( | $link | ) |
Clicks link with specified id|title|alt|text.
@When /^I follow "(?P<link_string>(?:[^"]|")*)"$/
ElementNotFoundException | Thrown by behat_base::find |
string | $link |
behat_general::database_family_used_is_one_of_the_following | ( | TableNode | $databasefamilies | ) |
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. |
Moodle |
behat_general::dismiss_currently_displayed_alert_dialog | ( | ) |
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$/
behat_general::download_file_from_link | ( | $link | ) |
Given the text of a link, download the linked file and return the contents.
This is a helper method used by } * and following_should_download_between_and_bytes()
string | $link | the text of the link. |
string | the content of the downloaded file. |
|
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 |
behat_general::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.
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. |
behat_general::following_should_download_bytes | ( | $link, | |
$expectedsize | |||
) |
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. |
behat_general::following_should_exist_in_the_table | ( | $table, | |
TableNode | $data | ||
) |
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| |
behat_general::following_should_not_exist_in_the_table | ( | $table, | |
TableNode | $data | ||
) |
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 |
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 |
|
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 |
|
protected |
Helper used by } * and a_new_page_should_not_have_loaded_since_i_started_watching.
string | xpath expression. |
|
staticinherited |
Return a list of the partial named selectors for the component.
Like the exact named selectors above, but the locator only needs to match part of the text. For example, the standard "button" is a partial selector, so: When I click "Save" "button" will activate "Save changes".
behat_component_named_selector[] |
Reimplemented in behat_message.
|
staticprotectedinherited |
Gets the required timeout in seconds.
int | $timeout | One of the TIMEOUT constants |
int | Actual timeout (in seconds) |
|
staticinherited |
Gets the reduced timeout.
A reduced timeout for cases where self::get_timeout() is too much and a simple $this->getSession()->getPage()->find() could not be enough.
int | Timeout in seconds |
|
protectedinherited |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions.
Use behat_base::get_text_selector_node() for text-based selectors.
ElementNotFoundException | Thrown by behat_base::find |
string | $selectortype | |
string | $element |
NodeElement |
|
protectedinherited |
Get the actual user in the behat session (note $USER does not correspond to the behat session's user).
mixed |
coding_exception |
|
inherited |
Get the session key for the current session via Javascript.
string |
|
protectedinherited |
Gets a NodeElement based on the locator and selector type received as argument from steps definitions.
ElementNotFoundException | Thrown by behat_base::find |
string | $selectortype | |
string | $element |
NodeElement |
|
staticinherited |
Gets the default timeout.
The timeout for each Behat step (load page, wait for an element to load...).
int | Timeout in seconds |
|
inherited |
Checks if the current scenario, or its feature, has a specified tag.
string | $tag | Tag to check |
bool | True if the tag exists in scenario or feature |
behat_general::i_am_on_course_index | ( | ) |
Opens course index page.
@Given /^I am on course index$/
behat_general::i_am_on_homepage | ( | ) |
Opens Moodle homepage.
@Given /^I am on homepage$/
behat_general::i_am_on_site_homepage | ( | ) |
Opens Moodle site homepage.
@Given /^I am on site homepage$/
behat_general::i_change_window_size_to | ( | $windowviewport, | |
$windowsize | |||
) |
Change browser window size small: 640x480, medium: 1024x768, large: 2560x1600, custom: widthxheight.
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 "(small|medium|large|d+x\d+)"$/ @Then /^I change the (window|viewport) size to "(small|medium|large|d+x\d+)"$/ |
string | $windowsize | size of the window (small|medium|large|wxh). |
behat_general::i_click_on | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_click_on_confirming_the_dialogue | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_click_on_dismissing_the_dialogue | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_click_on_in_the | ( | $element, | |
$selectortype, | |||
$nodeelement, | |||
$nodeselectortype | |||
) |
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 |
behat_general::i_click_on_skipping_visibility_check | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_drag_and_i_drop_it_in | ( | $source, | |
$sourcetype, | |||
$target, | |||
$targettype | |||
) |
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 |
behat_general::i_hover | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_manually_press_tab | ( | $shift = '' | ) |
Manually press tab key.
@When /^I press( shift)? tab$/
string | $shift | string optional step verifier |
DriverException |
behat_general::i_pause_scenario_execution | ( | ) |
Wait unit user press Enter/Return key.
Useful when debugging a scenario.
@Then /^(?:|I )pause(?:| scenario execution)$/
behat_general::i_post_tab_key_in_element | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_press_in_the_browser | ( | $button | ) |
Presses a given button in the browser.
NOTE: Phantomjs and goutte 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 |
behat_general::i_press_key_in_element | ( | $key, | |
$element, | |||
$selectortype | |||
) |
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 |
behat_general::i_run_all_adhoc_tasks | ( | ) |
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 |
behat_general::i_run_the_scheduled_task | ( | $taskname | ) |
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/tool/task/cli/schedule_task.php.
@Given /^I run the scheduled task "(?P<task_name>[^"]+)"$/
string | $taskname | Name of task e.g. 'mod_whatever\task\do_something' |
behat_general::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.
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. |
behat_general::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.
@Given /^I start watching to see if a new page loads$/
behat_general::i_take_focus_off_field | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::i_trigger_cron | ( | ) |
This step triggers cron like a user would do going to admin/cron.php.
@Given /^I trigger cron$/
behat_general::i_visit | ( | $localurl | ) |
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. |
behat_general::i_wait_seconds | ( | $seconds | ) |
Waits X seconds.
Required after an action that requires data from an AJAX request.
@Then /^I wait "(?P<seconds_number>\d+)" seconds$/
int | $seconds |
behat_general::i_wait_to_be_redirected | ( | ) |
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$/
behat_general::in_the_should_be_visible | ( | $element, | |
$selectortype, | |||
$nodeelement, | |||
$nodeselectortype | |||
) |
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 |
behat_general::in_the_should_not_be_visible | ( | $element, | |
$selectortype, | |||
$nodeelement, | |||
$nodeselectortype | |||
) |
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 |
|
protectedinherited |
Checks if the current page is part of the mobile app.
bool | True if it's in the app |
|
protectedinherited |
Trigger click on node via javascript instead of actually clicking on it via pointer.
This function resolves the issue of nested elements with click listeners or links - in these cases clicking via the pointer may accidentally cause a click on the wrong element. Example of issue: clicking to expand navigation nodes when the config value linkadmincategories is enabled.
NodeElement | $node |
|
protectedinherited |
Locates url, based on provided path.
Override to provide custom routing mechanism.
string | $path |
string |
|
inherited |
Internal step definition to find exceptions, debugging() messages and PHP debug messages.
Part of behat_hooks class as is part of the testing framework, is auto-executed after each step so no features will splicitly use it.
Exception | Unknown type, depending on what we caught in the hook or basic Exception. |
|
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 |
behat_general::reload | ( | ) |
Reloads the current page.
@Given /^I reload the page$/
|
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.
behat_general::row_column_of_table_should_contain | ( | $row, | |
$column, | |||
$table, | |||
$value | |||
) |
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. |
behat_general::row_column_of_table_should_not_contain | ( | $row, | |
$column, | |||
$table, | |||
$value | |||
) |
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. |
|
protectedinherited |
Whether Javascript is available in the current Session.
boolean |
|
staticprotectedinherited |
Whether Javascript is available in the specified Session.
Session | $session |
boolean |
|
staticinherited |
Set current $USER, reset access cache.
In some cases, behat will execute the code as admin but in many cases we need to set an specific user as some API's might rely on the logged user to take some action.
null | int | stdClass | $user | user record, null or 0 means non-logged-in, positive integer means userid |
behat_general::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.
@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 |
behat_general::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.
@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 |
behat_general::should_be_visible | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::should_exist | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::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.
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 |
string | $containerelement | The container selector type |
string | $containerselectortype | The container locator |
behat_general::should_not_be_visible | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::should_not_exist | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::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.
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 |
string | $containerelement | The container selector type |
string | $containerselectortype | The container locator |
|
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 |
behat_general::switch_to_class_iframe | ( | $classname | ) |
Switches to the iframe containing specified class.
@Given /^I switch to "(?P<iframe_name_string>(?:[^"]|")*)" class iframe$/
string | $classname |
behat_general::switch_to_iframe | ( | $iframename | ) |
Switches to the specified iframe.
@Given /^I switch to "(?P<iframe_name_string>(?:[^"]|")*)" iframe$/
string | $iframename |
behat_general::switch_to_the_main_frame | ( | ) |
Switches to the main Moodle frame.
@Given /^I switch to the main frame$/
behat_general::switch_to_the_main_window | ( | ) |
Switches to the main Moodle window.
Useful when you finish interacting with popup windows.
@Given /^I switch to the main window$/
behat_general::switch_to_window | ( | $windowname | ) |
Switches to the specified window.
Useful when interacting with popup windows.
@Given /^I switch to "(?P<window_name_string>(?:[^"]|")*)" window$/
string | $windowname |
behat_general::the_attribute_of_should_contain | ( | $attribute, | |
$element, | |||
$selectortype, | |||
$text | |||
) |
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 |
behat_general::the_attribute_of_should_not_contain | ( | $attribute, | |
$element, | |||
$selectortype, | |||
$text | |||
) |
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 |
behat_general::the_element_should_be_disabled | ( | $element, | |
$selectortype | |||
) |
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. |
behat_general::the_element_should_be_enabled | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::the_element_should_be_readonly | ( | $element, | |
$selectortype | |||
) |
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. |
behat_general::the_element_should_not_be_readonly | ( | $element, | |
$selectortype | |||
) |
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. |
behat_general::the_focused_element_is | ( | $not, | |
$nodeelement, | |||
$nodeselectortype | |||
) |
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 |
behat_general::the_focused_element_is_in_the | ( | $not, | |
$element, | |||
$selectortype, | |||
$nodeelement, | |||
$nodeselectortype | |||
) |
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 |
behat_general::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.
@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 |
|
protectedinherited |
Transforms from step definition's argument style to Mink format.
Mink has 3 different selectors css, xpath and named, where named selectors includes link, button, field... to simplify and group multiple steps in one we use the same interface, considering all link, buttons... at the same level as css selectors and xpath; this method makes the conversion from the arguments received by the steps to the selectors and locators required to interact with Mink.
ExpectationException |
string | $selectortype | It can be css, xpath or any of the named selectors. |
string | $element | The locator (or string) we are looking for. |
array | Contains the selector and the locator expected by Mink. |
|
protectedinherited |
Transforms from step definition's argument style to Mink format.
Delegates all the process to behat_base::transform_selector() checking the provided $selectortype.
ExpectationException |
string | $selectortype | It can be css, xpath or any of the named selectors. |
string | $element | The locator (or string) we are looking for. |
array | Contains the selector and the locator expected by Mink. |
|
inherited |
Waits for all the JS to be loaded.
bool | Whether any JS is still pending completion. |
|
staticinherited |
Waits for all the JS to be loaded.
Session | $session | The Mink Session where JS can be run |
bool | Whether any JS is still pending completion. |
behat_general::wait_until_does_not_exists | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::wait_until_exists | ( | $element, | |
$selectortype | |||
) |
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 |
behat_general::wait_until_the_page_is_ready | ( | ) |
Waits until the page is completely loaded.
This step is auto-executed after every step.
@Given /^I wait until the page is ready$/
|
inherited |
And extended timeout for specific cases.
string const behat_general::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.
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.
|
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...).