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

Add generic steps definitions to use with all kind of selectors

XMLWordPrintable

    • MOODLE_25_STABLE
    • MOODLE_25_STABLE
    • MDL-38025_master
    • Hide
      1. Copy the attached MDL-38025.feature file to admin/tool/behat/tests/behat/
      2. Install and enable your behat test site
      3. Run behat with the option --tags @MDL-38025
      4. You SHOULD see two fails, the scenario name explains what is the expected fail message
      Show
      Copy the attached MDL-38025 .feature file to admin/tool/behat/tests/behat/ Install and enable your behat test site Run behat with the option --tags @ MDL-38025 You SHOULD see two fails, the scenario name explains what is the expected fail message

      We are supposed to write tests that people can understand, reading them as plain English text, and the named selectors are the most appropriate way to do it. But sometimes named selectors are not enough and we would need to change moodle code to add more 'named' info or to be more specific when selecting DOM nodes. Also, we don't know about what uses people will give to the moodle-behat integration.

      Rather than having different steps(I should see "ASD" in the "#box-id" CSS element, I should see "Moodle" in the "First name" field...) which ends up being the same, we can add an extra argument and point tests writers to the reference with the options they have in the Acceptance testing UI.

      The options would be the same Behat provides, but using named selectors, css selectors and XPath at the same level and always the same set to make them easy to remember:

      • link - for searching a link by its href, id, title, img alt or value
      • button - for searching a button by its name, id, value, img alt or title
      • link_or_button - for searching for both, links and buttons
      • content - for searching a specific page content (text)
      • select - for searching a select field by its id, name or label
      • checkbox - for searching a checkbox by its id, name, or label
      • radio - for searching a radio button by its id, name, or label
      • file - for searching a file input by its id, name, or label
      • optgroup - for searching optgroup by its label
      • option - for searching an option by its content
      • table - for searching a table by its id or caption
      • field - for searching a field by its id, name, value or label
      • fieldset - for searching a fieldset by it's id or legend
      • css_element - for searching an element by its CSS selector
      • xpath_element - for searching an element by its XPath

      With this our steps can be:

      • I hover "Edit my profile" "link"
      • I click "Save changes" "button"
      • I should see "Marinated meat" in the "#grocery-list" "css_element"

            dmonllao David Monllaó
            dmonllao David Monllaó
            Frédéric Massart Frédéric Massart
            Aparup Banerjee Aparup Banerjee
            Rajesh Taneja Rajesh Taneja
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

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