Helps
- Alternatives to css :contains() selector
We use this selector in many tests, for example the ones that require to click on the link of a specific table row:
within "tr:contains('My Line')" do
click_link "Edit"
end
This selector however is deprecated, and didn’t make it to css3.
Thus, is it safe to use it in tests?
Suggestions
- Iterate over all the links
- Put an id on the link
- Probably not going away (and contains back in if it breaks)
- Data attribute
- Xpath – last resort