Reputation: 563
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.
Upvotes: 7
Views: 3510
Reputation: 31
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)
Upvotes: 2
Reputation: 11705
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.)
Upvotes: 7