Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 311 and 400] [Versions 311 and 401] [Versions 311 and 402] [Versions 311 and 403]

Steps definitions related with forms.

Copyright: 2012 David MonllaĆ³
License: http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
File Size: 754 lines (31 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 2 files
 lib/behat/behat_field_manager.php
 lib/behat/behat_base.php

Defines 1 class


Class: behat_forms  - X-Ref

Forms-related steps definitions.

Note, Behat tests to verify that the steps defined here work as advertised
are kept in admin/tool/behat/tests/behat.

press_button($button)   X-Ref
Presses button with specified id|name|title|alt|value.

param: string $button

press_button_and_switch_to_main_window($button)   X-Ref
Press button with specified id|name|title|alt|value and switch to main window.

param: string $button

i_set_the_following_fields_to_these_values(TableNode $data)   X-Ref
Fills a form with field/value data.

param: TableNode $data

i_set_the_following_fields_in_container_to_these_values($containerelement, $containerselectortype, TableNode $data)   X-Ref
Fills a form with field/value data.

param: string $containerelement Element we look in
param: string $containerselectortype The type of selector where we look in
param: TableNode $data

i_expand_all_fieldsets()   X-Ref
Expands all moodleform's fields, including collapsed fieldsets and advanced fields if they are present.


expand_all_fields()   X-Ref
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.

return: void

i_set_the_field_to_local_url($field, $path)   X-Ref
Sets the field to wwwroot plus the given path. Include the first slash.

param: string $field
param: string $path
return: void

i_set_the_field_to($field, $value)   X-Ref
Sets the specified value to the field.

param: string $field
param: string $value
return: void

i_set_the_field_in_container_to($field, $containerelement, $containerselectortype, $value)   X-Ref
Sets the specified value to the field.

param: string $field
param: string $containerelement Element we look in
param: string $containerselectortype The type of selector where we look in
param: string $value

i_press_key_in_the_field($key, $field)   X-Ref
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

param: string $key either char-code or character itself,
param: string $field
return: void

i_set_the_field_to_multiline($field, PyStringNode $value)   X-Ref
Sets the specified value to the field.

param: string $field
param: PyStringNode $value
return: void

i_set_the_field_with_xpath_to($fieldxpath, $value)   X-Ref
Sets the specified value to the field with xpath.

param: string $field
param: string $value
return: void

the_field_matches_value($field, $value)   X-Ref
Checks, the field matches the value.

param: string $field
param: string $value
return: void

the_field_matches_multiline($field, PyStringNode $value)   X-Ref
Checks, the field matches the value.

param: string $field
param: PyStringNode $value
return: void

the_field_does_not_match_value($field, $value)   X-Ref
Checks, the field does not match the value.

param: string $field
param: string $value

the_field_in_container_matches_value($field, $containerelement, $containerselectortype, $value)   X-Ref
Checks, the field matches the value.

param: string $field
param: string $containerelement Element we look in
param: string $containerselectortype The type of selector where we look in
param: string $value

the_field_in_container_does_not_match_value($field, $containerelement, $containerselectortype, $value)   X-Ref
Checks, the field does not match the value.

param: string $field
param: string $containerelement Element we look in
param: string $containerselectortype The type of selector where we look in
param: string $value

the_field_with_xpath_matches_value($fieldxpath, $value)   X-Ref
Checks, the field matches the value.

param: string $fieldxpath
param: string $value
return: void

the_field_with_xpath_does_not_match_value($fieldxpath, $value)   X-Ref
Checks, the field does not match the value.

param: string $fieldxpath
param: string $value
return: void

the_following_fields_match_these_values(TableNode $data)   X-Ref
Checks, the provided field/value matches.

param: TableNode $data Pairs of | field | value |

the_following_fields_do_not_match_these_values(TableNode $data)   X-Ref
Checks that the provided field/value pairs don't match.

param: TableNode $data Pairs of | field | value |

the_following_fields_in_container_match_these_values($containerelement, $containerselectortype, TableNode $data)   X-Ref
Checks, the provided field/value matches.

param: string $containerelement Element we look in
param: string $containerselectortype The type of selector where we look in
param: TableNode $data Pairs of | field | value |

the_following_fields_in_container_do_not_match_these_values($containerelement, $containerselectortype, TableNode $data)   X-Ref
Checks that the provided field/value pairs don't match.

param: string $containerelement Element we look in
param: string $containerselectortype The type of selector where we look in
param: TableNode $data Pairs of | field | value |

the_select_box_should_contain($select, $option)   X-Ref
Checks, that given select box contains the specified option.

param: string $select The select element name
param: string $option The option text/value. Plain value or comma separated

the_select_box_should_not_contain($select, $option)   X-Ref
Checks, that given select box does not contain the specified option.

param: string $select The select element name
param: string $option The option text/value. Plain value or comma separated

set_field_value($fieldlocator, $value)   X-Ref
Generic field setter.

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

param: string $fieldlocator The pointer to the field, it will depend on the field type.
param: string $value
return: void

set_field_node_value(NodeElement $fieldnode, string $value)   X-Ref
Generic field setter to be used by chainable steps.

param: NodeElement $fieldnode
param: string $value

set_field_value_in_container($fieldlocator, $value, $containerselectortype, $containerelement)   X-Ref
Generic field setter.

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

param: string $fieldlocator The pointer to the field, it will depend on the field type.
param: string $value the value to set
param: string $containerselectortype The type of selector where we look in
param: string $containerelement Element we look in

i_select_from_the_singleselect($option, $singleselect)   X-Ref
Select a value from single select and redirect.


i_click_on_item_in_the_autocomplete_list($item)   X-Ref
Select item from autocomplete list.

param: string $item

i_open_the_autocomplete_suggestions_list($container = null, $containertype = null)   X-Ref
Open the auto-complete suggestions list (Assuming there is only one on the page.).


i_expand_the_autocomplete($field)   X-Ref
Expand the given autocomplete list

param: string $field Field name

i_should_see_in_the_list_of_option_for_the_autocomplete($option, $field)   X-Ref
Assert the given option exist in the given autocomplete list

param: string $option Name of option
param: string $field Field name