I'm trying to check a checkbox in my cucumber test, but I cannot figure out how to tell it to search by anything other than the id, name, or label. I keep on getting this error:
cannot check field, no checkbox with id, name, or label 'xxxx' found
I have added an attribute of 'identifier' to each checkbox, with unique values, and would like to find the box by these terms.
Do you mean that you've added a new attribute named identifier
to each checkbox? If so then you may be able to find them using a CSS locator:
find(:css, "[identifier='#{my_checkbox_identifier}']").set(true)
(set
-ing the checkbox to true
checks it, use false
to uncheck it.)
Realizing this question is rather old, an answer may still be useful to someone, somewhere. I found the following to work:
find(:xpath, "//input[@identifier='my_checkbox_identifier']").set(true)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With