-
New Feature
-
Resolution: Fixed
-
Minor
-
2.5
-
MOODLE_25_STABLE
-
MOODLE_25_STABLE
-
MDL-38025_master -
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"