MDL-68353 test: get_field_locator to support custom field labels

This commit is contained in:
Shamim Rezaie
2020-05-29 14:51:58 +10:00
parent 2591f4ce79
commit 32d28f8fac
2 changed files with 4 additions and 2 deletions
+3 -1
View File
@@ -221,7 +221,9 @@ XPATH
.//*[contains(., %locator%) and not(.//*[contains(., %locator%)])]
XPATH
, 'form_row' => <<<XPATH
.//*[self::label or self::div[contains(concat(' ', @class, ' '), ' fstaticlabel ')]][contains(., %locator%)]/ancestor::*[contains(concat(' ', @class, ' '), ' fitem ')]
.//*[contains(concat(' ', @class, ' '), ' col-form-label ')]
[normalize-space(.)= %locator%]
/ancestor::*[contains(concat(' ', @class, ' '), ' fitem ')]
XPATH
, 'autocomplete_selection' => <<<XPATH
.//div[contains(concat(' ', normalize-space(@class), ' '), concat(' ', 'form-autocomplete-selection', ' '))]/span[@role='listitem'][contains(normalize-space(.), %locator%)]
+1 -1
View File
@@ -251,7 +251,7 @@ class behat_form_field {
// Defaults to label.
if ($locatortype == 'label' || $locatortype == false) {
$labelnode = $this->session->getPage()->find('xpath', '//label[@for="' . $fieldid . '"]');
$labelnode = $this->session->getPage()->find('xpath', "//label[@for='$fieldid']|//p[@id='{$fieldid}_label']");
// Exception only if $locatortype was specified.
if (!$labelnode && $locatortype == 'label') {