-
Improvement
-
Resolution: Unresolved
-
Minor
-
None
-
4.0
-
None
-
MOODLE_400_STABLE
In my experience, the only times you have to use the "css_element" and "xpath_element" selectors in Behat tests is when you have an accessibility bug (that the thing you want to interact with does not have a label, or the label is too ambiguous to be useful).
Moodle cares about accessibility. If there are accessibility bugs, we should fix them.
Therefore, I think we should ban the use of these selectors.
Starting with a complete ban right now is probably unrelalistic. Perhaps a softer way to start is by getting gherkinlint to warn about the. This can be done crudely with
"no-restricted-patterns": ["on", {
|
"Global": ["\"css_element\"", "\"xpath_element\""]
|
}]
|
which gives
Running "gherkinlint" task
|
[HIDDEN]\report\log\tests\behat\filter_log.feature
|
27 Step text: "I click on ".frog" "css_element"" matches restricted pattern "/"css_element"/i" no-restricted-patterns
|
or if we wrote a custom rule, we could probably get a more developer-friendly error message.