Moodle APIs 3.9
Moodle 3.9.13+ (Build: 20220325)
Public Member Functions | Public Attributes | Protected Member Functions | List of all members
behat_forms Class Reference
Inheritance diagram for behat_forms:
behat_base behat_session_interface

Public Member Functions

 getSession ($name=null)
 Returns the Mink session. More...
 
 i_click_on_item_in_the_autocomplete_list ($item)
 Select item from autocomplete list. More...
 
 i_expand_all_fieldsets ()
 Expands all moodleform's fields, including collapsed fieldsets and advanced fields if they are present. More...
 
 i_expand_the_autocomplete ($field)
 Expand the given autocomplete list. More...
 
 i_open_the_autocomplete_suggestions_list ($container=null, $containertype=null)
 Open the auto-complete suggestions list (Assuming there is only one on the page.). More...
 
 i_press_key_in_the_field ($key, $field)
 Press the key in the field to trigger the javascript keypress event. More...
 
 i_select_from_the_singleselect ($option, $singleselect)
 Select a value from single select and redirect. More...
 
 i_set_the_field_in_container_to ($field, $containerelement, $containerselectortype, $value)
 Sets the specified value to the field. More...
 
 i_set_the_field_to ($field, $value)
 Sets the specified value to the field. More...
 
 i_set_the_field_to_local_url ($field, $path)
 Sets the field to wwwroot plus the given path. More...
 
 i_set_the_field_to_multiline ($field, PyStringNode $value)
 Sets the specified value to the field. More...
 
 i_set_the_field_with_xpath_to ($fieldxpath, $value)
 Sets the specified value to the field with xpath. More...
 
 i_set_the_following_fields_in_container_to_these_values ( $containerelement, $containerselectortype, TableNode $data)
 Fills a form with field/value data. More...
 
 i_set_the_following_fields_to_these_values (TableNode $data)
 Fills a form with field/value data. More...
 
 i_should_see_in_the_list_of_option_for_the_autocomplete ($option, $field)
 Assert the given option exist in the given autocomplete list. More...
 
 press_button ($button)
 Presses button with specified id|name|title|alt|value. More...
 
 press_button_and_switch_to_main_window ($button)
 Press button with specified id|name|title|alt|value and switch to main window. More...
 
 set_field_node_value (NodeElement $fieldnode, string $value)
 Generic field setter to be used by chainable steps. More...
 
 the_field_does_not_match_value ($field, $value)
 Checks, the field does not match the value. More...
 
 the_field_in_container_does_not_match_value ($field, $containerelement, $containerselectortype, $value)
 Checks, the field does not match the value. More...
 
 the_field_in_container_matches_value ($field, $containerelement, $containerselectortype, $value)
 Checks, the field matches the value. More...
 
 the_field_matches_multiline ($field, PyStringNode $value)
 Checks, the field matches the value. More...
 
 the_field_matches_value ($field, $value)
 Checks, the field matches the value. More...
 
 the_field_with_xpath_does_not_match_value ($fieldxpath, $value)
 Checks, the field does not match the value. More...
 
 the_field_with_xpath_matches_value ($fieldxpath, $value)
 Checks, the field matches the value. More...
 
 the_following_fields_do_not_match_these_values (TableNode $data)
 Checks that the provided field/value pairs don't match. More...
 
 the_following_fields_in_container_do_not_match_these_values ( $containerelement, $containerselectortype, TableNode $data)
 Checks that the provided field/value pairs don't match. More...
 
 the_following_fields_in_container_match_these_values ( $containerelement, $containerselectortype, TableNode $data)
 Checks, the provided field/value matches. More...
 
 the_following_fields_match_these_values (TableNode $data)
 Checks, the provided field/value matches. More...
 
 the_select_box_should_contain ($select, $option)
 Checks, that given select box contains the specified option. More...
 
 the_select_box_should_not_contain ($select, $option)
 Checks, that given select box does not contain the specified option. More...
 

Public Attributes

const EXTENDED_TIMEOUT = 10
 And extended timeout for specific cases. More...
 
const PAGE_READY_JS
 The JS code to check that the page is ready. More...
 
const REDUCED_TIMEOUT = 2
 Small timeout. More...
 
const TIMEOUT = 6
 The timeout for each Behat step (load page, wait for an element to load...). More...
 

Protected Member Functions

 expand_all_fields ()
 Expands all moodle form fieldsets if they exists. More...
 
 set_field_value ($fieldlocator, $value)
 Generic field setter. More...
 
 set_field_value_in_container ($fieldlocator, $value, $containerselectortype, $containerelement)
 Generic field setter. More...
 

Member Function Documentation

◆ expand_all_fields()

behat_forms::expand_all_fields ( )
protected

Expands all moodle form fieldsets if they exists.

Externalized from i_expand_all_fields to call it from other form-related steps without having to use steps-group calls.

Exceptions
ElementNotFoundExceptionThrown by behat_base::find_all
Return values
void

◆ getSession()

behat_session_interface::getSession (   $name = null)
inherited

Returns the Mink session.

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

Implemented in behat_form_field.

◆ i_click_on_item_in_the_autocomplete_list()

behat_forms::i_click_on_item_in_the_autocomplete_list (   $item)

Select item from autocomplete list.

@Given /^I click on "([^"]*)" item in the autocomplete list$/

Parameters
string$item

◆ i_expand_all_fieldsets()

behat_forms::i_expand_all_fieldsets ( )

Expands all moodleform's fields, including collapsed fieldsets and advanced fields if they are present.

@Given /^I expand all fieldsets$/

◆ i_expand_the_autocomplete()

behat_forms::i_expand_the_autocomplete (   $field)

Expand the given autocomplete list.

@Given /^I expand the "(?P<field_string>(?:[^"]|::")*)" autocomplete$/

Parameters
string$fieldField name

◆ i_open_the_autocomplete_suggestions_list()

behat_forms::i_open_the_autocomplete_suggestions_list (   $container = null,
  $containertype = null 
)

Open the auto-complete suggestions list (Assuming there is only one on the page.).

@Given I open the autocomplete suggestions list @Given I open the autocomplete suggestions list in the :container :containertype

◆ i_press_key_in_the_field()

behat_forms::i_press_key_in_the_field (   $key,
  $field 
)

Press the key in the field to trigger the javascript keypress event.

Note that the character key will not actually be typed in the input field

@Given /^I press key "(?P<key_string>(?:[^"]|::")*)" in the field "(?P<field_string>(?:[^"]|")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$keyeither char-code or character itself, may optionally be prefixed with ctrl-, alt-, shift- or meta-
string$field
Return values
void

◆ i_select_from_the_singleselect()

behat_forms::i_select_from_the_singleselect (   $option,
  $singleselect 
)

Select a value from single select and redirect.

@Given /^I select "(?P<singleselect_option_string>(?:[^"]|::")*)" from the "(?P<singleselect_name_string>(?:[^"]|")*)" singleselect$/

◆ i_set_the_field_in_container_to()

behat_forms::i_set_the_field_in_container_to (   $field,
  $containerelement,
  $containerselectortype,
  $value 
)

Sets the specified value to the field.

@Given /^I set the field "(?P<field_string>(?:[^"]|::")*)" in the "(?P<element_container_string>(?:[^"]|")*)" "(?P<text_selector_string>[^"]*)" to "(?P<field_value_string>(?:[^"]|::")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$containerelementElement we look in
string$containerselectortypeThe type of selector where we look in
string$value

◆ i_set_the_field_to()

behat_forms::i_set_the_field_to (   $field,
  $value 
)

Sets the specified value to the field.

@Given /^I set the field "(?P<field_string>(?:[^"]|::")*)" to "(?P<field_value_string>(?:[^"]|")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$value
Return values
void

◆ i_set_the_field_to_local_url()

behat_forms::i_set_the_field_to_local_url (   $field,
  $path 
)

Sets the field to wwwroot plus the given path.

Include the first slash.

@Given /^I set the field "(?P<field_string>(?:[^"]|::")*)" to local url "(?P<field_path_string>(?:[^"]|")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$path
Return values
void

◆ i_set_the_field_to_multiline()

behat_forms::i_set_the_field_to_multiline (   $field,
PyStringNode  $value 
)

Sets the specified value to the field.

@Given /^I set the field "(?P<field_string>(?:[^"]|::")*)" to multiline:$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
PyStringNode$value
Return values
void

◆ i_set_the_field_with_xpath_to()

behat_forms::i_set_the_field_with_xpath_to (   $fieldxpath,
  $value 
)

Sets the specified value to the field with xpath.

@Given /^I set the field with xpath "(?P<fieldxpath_string>(?:[^"]|::")*)" to "(?P<field_value_string>(?:[^"]|")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$value
Return values
void

◆ i_set_the_following_fields_in_container_to_these_values()

behat_forms::i_set_the_following_fields_in_container_to_these_values (   $containerelement,
  $containerselectortype,
TableNode  $data 
)

Fills a form with field/value data.

@Given /^I set the following fields in the "(?P<element_container_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)" to these values:$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$containerelementElement we look in
string$containerselectortypeThe type of selector where we look in
TableNode$data

◆ i_set_the_following_fields_to_these_values()

behat_forms::i_set_the_following_fields_to_these_values ( TableNode  $data)

Fills a form with field/value data.

@Given /^I set the following fields to these values:$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
TableNode$data

◆ i_should_see_in_the_list_of_option_for_the_autocomplete()

behat_forms::i_should_see_in_the_list_of_option_for_the_autocomplete (   $option,
  $field 
)

Assert the given option exist in the given autocomplete list.

@Given /^I should see "(?P<option_string>(?:[^"]|::")*)" in the list of options for the "(?P<field_string>(?:[^"]|")*)" autocomplete$$/

Parameters
string$optionName of option
string$fieldField name

◆ press_button()

behat_forms::press_button (   $button)

Presses button with specified id|name|title|alt|value.

@When /^I press "(?P<button_string>(?:[^"]|::")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$button

◆ press_button_and_switch_to_main_window()

behat_forms::press_button_and_switch_to_main_window (   $button)

Press button with specified id|name|title|alt|value and switch to main window.

@When /^I press "(?P<button_string>(?:[^"]|::")*)" and switch to main window$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$button

◆ set_field_node_value()

behat_forms::set_field_node_value ( NodeElement  $fieldnode,
string  $value 
)

Generic field setter to be used by chainable steps.

Parameters
NodeElement$fieldnode
string$value

◆ set_field_value()

behat_forms::set_field_value (   $fieldlocator,
  $value 
)
protected

Generic field setter.

Internal API method, a generic I set "VALUE" to "FIELD" field could be created based on it.

Parameters
string$fieldlocatorThe pointer to the field, it will depend on the field type.
string$value
Return values
void

◆ set_field_value_in_container()

behat_forms::set_field_value_in_container (   $fieldlocator,
  $value,
  $containerselectortype,
  $containerelement 
)
protected

Generic field setter.

Internal API method, a generic I set "VALUE" to "FIELD" field could be created based on it.

Parameters
string$fieldlocatorThe pointer to the field, it will depend on the field type.
string$valuethe value to set
string$containerselectortypeThe type of selector where we look in
string$containerelementElement we look in

◆ the_field_does_not_match_value()

behat_forms::the_field_does_not_match_value (   $field,
  $value 
)

Checks, the field does not match the value.

@Then /^the field "(?P<field_string>(?:[^"]|::")*)" does not match value "(?P<field_value_string>(?:[^"]|")*)"$/

Exceptions
ExpectationException
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$value

◆ the_field_in_container_does_not_match_value()

behat_forms::the_field_in_container_does_not_match_value (   $field,
  $containerelement,
  $containerselectortype,
  $value 
)

Checks, the field does not match the value.

@Then /^the field "(?P<field_string>(?:[^"]|::")*)" in the "(?P<element_container_string>(?:[^"]|")*)" "(?P<text_selector_string>[^"]*)" does not match value "(?P<field_value_string>(?:[^"]|::")*)"$/

Exceptions
ExpectationException
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$containerelementElement we look in
string$containerselectortypeThe type of selector where we look in
string$value

◆ the_field_in_container_matches_value()

behat_forms::the_field_in_container_matches_value (   $field,
  $containerelement,
  $containerselectortype,
  $value 
)

Checks, the field matches the value.

@Then /^the field "(?P<field_string>(?:[^"]|::")*)" in the "(?P<element_container_string>(?:[^"]|")*)" "(?P<text_selector_string>[^"]*)" matches value "(?P<field_value_string>(?:[^"]|::")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$containerelementElement we look in
string$containerselectortypeThe type of selector where we look in
string$value

◆ the_field_matches_multiline()

behat_forms::the_field_matches_multiline (   $field,
PyStringNode  $value 
)

Checks, the field matches the value.

@Then /^the field "(?P<field_string>(?:[^"]|::")*)" matches multiline:$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
PyStringNode$value
Return values
void

◆ the_field_matches_value()

behat_forms::the_field_matches_value (   $field,
  $value 
)

Checks, the field matches the value.

@Then /^the field "(?P<field_string>(?:[^"]|::")*)" matches value "(?P<field_value_string>(?:[^"]|")*)"$/

Exceptions
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$field
string$value
Return values
void

◆ the_field_with_xpath_does_not_match_value()

behat_forms::the_field_with_xpath_does_not_match_value (   $fieldxpath,
  $value 
)

Checks, the field does not match the value.

@Then /^the field with xpath "(?P<xpath_string>(?:[^"]|::")*)" does not match value "(?P<field_value_string>(?:[^"]|")*)"$/

Exceptions
ExpectationException
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$fieldxpath
string$value
Return values
void

◆ the_field_with_xpath_matches_value()

behat_forms::the_field_with_xpath_matches_value (   $fieldxpath,
  $value 
)

Checks, the field matches the value.

@Then /^the field with xpath "(?P<xpath_string>(?:[^"]|::")*)" matches value "(?P<field_value_string>(?:[^"]|")*)"$/

Exceptions
ExpectationException
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$fieldxpath
string$value
Return values
void

◆ the_following_fields_do_not_match_these_values()

behat_forms::the_following_fields_do_not_match_these_values ( TableNode  $data)

Checks that the provided field/value pairs don't match.

@Then /^the following fields do not match these values:$/

Exceptions
ExpectationException
Parameters
TableNode$dataPairs of | field | value |

◆ the_following_fields_in_container_do_not_match_these_values()

behat_forms::the_following_fields_in_container_do_not_match_these_values (   $containerelement,
  $containerselectortype,
TableNode  $data 
)

Checks that the provided field/value pairs don't match.

@Then /^the following fields in the "(?P<element_container_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)" do not match these values:$/

Exceptions
ExpectationException
Parameters
string$containerelementElement we look in
string$containerselectortypeThe type of selector where we look in
TableNode$dataPairs of | field | value |

◆ the_following_fields_in_container_match_these_values()

behat_forms::the_following_fields_in_container_match_these_values (   $containerelement,
  $containerselectortype,
TableNode  $data 
)

Checks, the provided field/value matches.

@Then /^the following fields in the "(?P<element_container_string>(?:[^"]|::")*)" "(?P<text_selector_string>[^"]*)" match these values:$/

Exceptions
ExpectationException
Parameters
string$containerelementElement we look in
string$containerselectortypeThe type of selector where we look in
TableNode$dataPairs of | field | value |

◆ the_following_fields_match_these_values()

behat_forms::the_following_fields_match_these_values ( TableNode  $data)

Checks, the provided field/value matches.

@Then /^the following fields match these values:$/

Exceptions
ExpectationException
Parameters
TableNode$dataPairs of | field | value |

◆ the_select_box_should_contain()

behat_forms::the_select_box_should_contain (   $select,
  $option 
)

Checks, that given select box contains the specified option.

@Then /^the "(?P<select_string>(?:[^"]|::")*)" select box should contain "(?P<option_string>(?:[^"]|")*)"$/

Exceptions
ExpectationException
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$selectThe select element name
string$optionThe option text/value. Plain value or comma separated values if multiple. Commas in multiple values escaped with backslash.

◆ the_select_box_should_not_contain()

behat_forms::the_select_box_should_not_contain (   $select,
  $option 
)

Checks, that given select box does not contain the specified option.

@Then /^the "(?P<select_string>(?:[^"]|::")*)" select box should not contain "(?P<option_string>(?:[^"]|")*)"$/

Exceptions
ExpectationException
ElementNotFoundExceptionThrown by behat_base::find
Parameters
string$selectThe select element name
string$optionThe option text/value. Plain value or comma separated values if multiple. Commas in multiple values escaped with backslash.

Member Data Documentation

◆ EXTENDED_TIMEOUT

const behat_session_interface::EXTENDED_TIMEOUT = 10
inherited

And extended timeout for specific cases.

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_extended_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_extended_timeout()

◆ PAGE_READY_JS

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

The JS code to check that the page is ready.

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

◆ REDUCED_TIMEOUT

const behat_session_interface::REDUCED_TIMEOUT = 2
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.

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_reduced_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_reduced_timeout()

◆ TIMEOUT

const behat_session_interface::TIMEOUT = 6
inherited

The timeout for each Behat step (load page, wait for an element to load...).

Deprecated:
since Moodle 3.7 MDL-64979 - please use get_timeout() instead
Todo:
MDL-64982 This will be deleted in Moodle 3.11
See also
behat_base::get_timeout()

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