Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
behat_form_modvisible Class Reference

Allows interaction with fmodvisible form fields. More...

Inheritance diagram for behat_form_modvisible:
behat_form_select behat_form_field behat_session_interface

Public Member Functions

 get_attribute ($name)
 Get the value of an attribute set on this field.
 
 get_value ()
 Returns the text of the currently selected options.
 
 getSession ($name=null)
 Returns the Mink session.
 
 key_press ($char, $modifier=null)
 Presses specific keyboard key.
 
 matches ($expectedvalue)
 Returns whether the provided argument matches the current value.
 
 set_value ($value)
 Sets the value(s) of a select element.
 

Public Attributes

const PAGE_READY_JS
 The JS code to check that the page is ready.
 

Protected Member Functions

 get_field_instance_for_element (NodeElement $element)
 Returns the appropriate form field object for a given node element.
 
 get_field_locator ($locatortype=false)
 Gets the field locator.
 
 get_internal_field_id ()
 Gets the field internal id used by selenium wire protocol.
 
 get_option_xpath ($option, $selectxpath)
 Returns the opton XPath based on it's select xpath.
 
 get_selected_options ($returntexts=true)
 Returns the field selected values.
 
 get_unescaped_options ($value)
 Cleans the list of options and returns it as a string separating options with |||.
 
 running_javascript ()
 Returns whether the scenario is running in a browser that can run Javascript or not.
 
 text_matches ($expectedvalue, ?string $actualvalue=null)
 Checks if the provided text matches the field value.
 
 wait_for_pending_js ()
 Waits for all the JS activity to be completed.
 

Protected Attributes

NodeElement $field
 The field DOM node to interact with.
 
string $fieldlocator = false
 The field's locator.
 
Session $session
 Behat session.
 

Detailed Description

Allows interaction with fmodvisible form fields.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Plain behat_form_select extension as is the same kind of field.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Member Function Documentation

◆ get_attribute()

behat_form_field::get_attribute ( $name)
inherited

Get the value of an attribute set on this field.

Parameters
string$nameThe attribute name
Return values
stringThe attribute value

◆ get_field_instance_for_element()

behat_form_field::get_field_instance_for_element ( NodeElement $element)
protectedinherited

Returns the appropriate form field object for a given node element.

Parameters
NodeElement$elementThe node element
Return values
behat_form_field

◆ get_field_locator()

behat_form_field::get_field_locator ( $locatortype = false)
protectedinherited

Gets the field locator.

Defaults to the field label but you can specify other locators if you are interested.

Public visibility as in most cases will be hard to use this method in a generic way, as fields can be selected using multiple ways (label, id, name...).

Exceptions
coding_exception
Parameters
string$locatortype
Return values
string

◆ get_internal_field_id()

behat_form_field::get_internal_field_id ( )
protectedinherited

Gets the field internal id used by selenium wire protocol.

Only available when running_javascript().

Exceptions
coding_exception
Return values
int

◆ get_option_xpath()

behat_form_select::get_option_xpath ( $option,
$selectxpath )
protectedinherited

Returns the opton XPath based on it's select xpath.

Parameters
string$option
string$selectxpath
Return values
stringxpath

◆ get_selected_options()

behat_form_select::get_selected_options ( $returntexts = true)
protectedinherited

Returns the field selected values.

Externalized from the common behat_form_field API method get_value() as matches() needs to check against both values and texts.

Parameters
bool$returntextsReturns the options texts or the options values.
Return values
string

◆ get_unescaped_options()

behat_form_select::get_unescaped_options ( $value)
protectedinherited

Cleans the list of options and returns it as a string separating options with |||.

Parameters
string$valueThe string containing the escaped options.
Return values
stringThe options

◆ get_value()

behat_form_select::get_value ( )
inherited

Returns the text of the currently selected options.

Return values
stringComma separated if multiple options are selected. Commas in option texts escaped with backslash.

Reimplemented from behat_form_field.

◆ getSession()

behat_form_field::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

Implements behat_session_interface.

◆ key_press()

behat_form_field::key_press ( $char,
$modifier = null )
inherited

Presses specific keyboard key.

Parameters
mixed$charcould be either char ('b') or char-code (98)
string$modifierkeyboard modifier (could be 'ctrl', 'alt', 'shift' or 'meta')

◆ matches()

behat_form_select::matches ( $expectedvalue)
inherited

Returns whether the provided argument matches the current value.

Parameters
mixed$expectedvalue
Return values
bool

Reimplemented from behat_form_field.

◆ running_javascript()

behat_form_field::running_javascript ( )
protectedinherited

Returns whether the scenario is running in a browser that can run Javascript or not.

Return values
bool

◆ set_value()

behat_form_select::set_value ( $value)
inherited

Sets the value(s) of a select element.

Seems an easy select, but there are lots of combinations of browsers and operative systems and each one manages the autosubmits and the multiple option selects in a different way.

Parameters
string$valueplain value or comma separated values if multiple. Commas in values escaped with backslash.
Return values
void

Reimplemented from behat_form_field.

Reimplemented in behat_form_inplaceeditable_select.

◆ text_matches()

behat_form_field::text_matches ( $expectedvalue,
?string $actualvalue = null )
protectedinherited

Checks if the provided text matches the field value.

Parameters
string$expectedvalue
string | null$actualvalueThe actual value. If not specified, this will be fetched from $this->get_value().
Return values
bool

◆ wait_for_pending_js()

behat_form_field::wait_for_pending_js ( )
protectedinherited

Waits for all the JS activity to be completed.

Return values
boolWhether any JS is still pending completion.

Member Data Documentation

◆ 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.


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