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

Default behat named selectors are usually looking for locators that contains() rather than matches()

    XMLWordPrintable

    Details

    • Affected Branches:
      MOODLE_27_STABLE

      Description

      This issue is about overwriting the default behat named selectors (http://mink.behat.org/#named-selectors) which are using contains() rather than an equals comparison (https://github.com/Behat/Mink/blob/v1.5.0/src/Behat/Mink/Selector/NamedSelector.php#L20) which leads to misleading results when we can't point to the node we want to point and another one containing the text (+ other texts) that appears before in the DOM is selected rather than the one that matches exactly the same value.

      I've created this issue following Tim's comment: https://tracker.moodle.org/browse/MDL-44534?focusedCommentId=276667&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-276667

      Before changing something like the named selectors, that is part of the base of behat, I want to be completely sure that we are not missing something important as to me it makes a lot more sense to matches($asd) values rather than contains($asd).

      The technical solution is not specially a problem as we can overwrite them (I haven't tried it, it is what it seems though) in lib/behat/classes/behat_selectors.php using $session->getSelectorsHandler()>getSelector('named')>registerNamedXpath($name, $xpath)

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                2 Vote for this issue
                Watchers:
                6 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: