Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-74174

Policy discussion: deprecate use of "css_element" and "xpath_element" selectors in Behat

XMLWordPrintable

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

            Unassigned Unassigned
            timhunt Tim Hunt
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.