Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Static Public Member Functions | Static Protected Member Functions | List of all members
behat_field_manager Class Reference

Static Public Member Functions

static get_field (NodeElement $fieldnode, $locator, Session $session)
 Gets an instance of the form field. More...
 
static get_field_instance ($type, NodeElement $fieldnode, Session $session)
 Returns the appropiate behat_form_field according to the provided type. More...
 
static get_form_field (NodeElement $fieldnode, Session $session)
 Gets an instance of the form field. More...
 
static get_form_field_from_label ($label, RawMinkContext $context)
 Gets an instance of the form field from it's label. More...
 
static guess_field_type (NodeElement $fieldnode, Session $session)
 Guesses a basic field type and returns it. More...
 

Static Protected Member Functions

static get_field_node_type (NodeElement $fieldnode, Session $session)
 Recursive method to find the field type. More...
 
static get_node_type (NodeElement $fieldnode, $locator, Session $session)
 Recursive method to find the field type. More...
 
static is_moodleform_field (NodeElement $fieldnode)
 Detects when the field is a moodleform field type. More...
 

Member Function Documentation

◆ get_field()

static behat_field_manager::get_field ( NodeElement  $fieldnode,
  $locator,
Session  $session 
)
static

Gets an instance of the form field.

Not all the fields are part of a moodle form, in this cases it fallsback to the generic form field. Also note that this generic field type is using a generic setValue() method from the Behat API, which is not always good to set the value of form elements.

Deprecated:
since Moodle 2.6 MDL-39634 - please do not use this function any more.
Todo:
MDL-XXXXX This will be deleted in Moodle 2.8
See also
behat_field_manager::get_form_field()
Parameters
NodeElement$fieldnode
string$locator
Session$sessionThe behat browser session
Return values
behat_form_field

◆ get_field_instance()

static behat_field_manager::get_field_instance (   $type,
NodeElement  $fieldnode,
Session  $session 
)
static

Returns the appropiate behat_form_field according to the provided type.

It defaults to behat_form_field.

Parameters
string$typeThe field type (checkbox, date_selector, text...)
NodeElement$fieldnode
Session$sessionThe behat session
Return values
behat_form_field

◆ get_field_node_type()

static behat_field_manager::get_field_node_type ( NodeElement  $fieldnode,
Session  $session 
)
staticprotected

Recursive method to find the field type.

Depending on the field the felement class node is in a level or in another. We look recursively for a parent node with a 'felement' class to find the field type.

Parameters
NodeElement$fieldnodeThe current node.
Session$sessionThe behat browser session
Return values
mixedA NodeElement if we continue looking for the element type and String or false when we are done.

◆ get_form_field()

static behat_field_manager::get_form_field ( NodeElement  $fieldnode,
Session  $session 
)
static

Gets an instance of the form field.

Not all the fields are part of a moodle form, in this cases it fallsback to the generic form field. Also note that this generic field type is using a generic setValue() method from the Behat API, which is not always good to set the value of form elements.

Parameters
NodeElement$fieldnode
Session$sessionThe behat browser session
Return values
behat_form_field

◆ get_form_field_from_label()

static behat_field_manager::get_form_field_from_label (   $label,
RawMinkContext  $context 
)
static

Gets an instance of the form field from it's label.

Parameters
string$label
RawMinkContext$context
Return values
behat_form_field

◆ get_node_type()

static behat_field_manager::get_node_type ( NodeElement  $fieldnode,
  $locator,
Session  $session 
)
staticprotected

Recursive method to find the field type.

Depending on the field the felement class node is in a level or in another. We look recursively for a parent node with a 'felement' class to find the field type.

Deprecated:
since Moodle 2.6 MDL-39634 - please do not use this function any more.
Todo:
MDL-XXXXX This will be deleted in Moodle 2.8
See also
behat_field_manager::get_field_node_type()
Parameters
NodeElement$fieldnodeThe current node.
string$locator
Session$sessionThe behat browser session
Return values
mixedA NodeElement if we continue looking for the element type and String or false when we are done.

◆ guess_field_type()

static behat_field_manager::guess_field_type ( NodeElement  $fieldnode,
Session  $session 
)
static

Guesses a basic field type and returns it.

This method is intended to detect HTML form fields when no moodleform-specific elements have been detected.

Parameters
NodeElement$fieldnode
Session$session
Return values
string|boolThe field type or false.

◆ is_moodleform_field()

static behat_field_manager::is_moodleform_field ( NodeElement  $fieldnode)
staticprotected

Detects when the field is a moodleform field type.

Note that there are fields inside moodleforms that are not moodleform element; this method can not detect this, this will be managed by get_field_node_type, after failing to find the form element element type.

Parameters
NodeElement$fieldnode
Return values
bool

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