MDL-47410 behat: Use data-fieldtype attribute to guess the field type

The data-fieldtype attribute (if present) should be also utilized in
guess_field_type() and match the behavior in get_field_node_type().
This commit is contained in:
Mihail Geshoski 2021-02-11 11:38:00 +08:00
parent d46f1a3ef4
commit 896364e4c4

View File

@ -136,6 +136,11 @@ class behat_field_manager {
*/
public static function guess_field_type(NodeElement $fieldnode, Session $session) {
// If the type is explicitly set on the element pointed to by the label - use it.
if ($fieldtype = $fieldnode->getAttribute('data-fieldtype')) {
return self::normalise_fieldtype($fieldtype);
}
// Textareas are considered text based elements.
$tagname = strtolower($fieldnode->getTagName());
if ($tagname == 'textarea') {
@ -151,10 +156,6 @@ class behat_field_manager {
$type = $fieldnode->getAttribute('type');
switch ($type) {
case 'text':
if ($fieldtype = $fieldnode->getAttribute('data-fieldtype')) {
return self::normalise_fieldtype($fieldtype);
}
return 'text';
case 'password':
case 'email':
case 'file':