Reputation: 71
I can't get my test to set a checkbox. Tried all kinds of hints found on Google, but nothing seems to work.
The source for the checkbox is
<div class="ish-field buttons-conditions">
<div class="accept-conditions">
<input tabindex="30"
type="checkbox"
class="ish-input-regular-news"
id="RegisterUserFullEmail_Accepted-1"
value="true"
name="RegisterUserFullEmail_Accepted"
The checkbox is visible on the page.
I would expect to be able to simply do: check("RegisterUserFullEmail_Accepted-1")
but that doesn't work.
Any suggestions?
Upvotes: 0
Views: 476
Reputation: 49870
On the page you're attempting to drive https://www.plus.nl/registreren the checkboxes are actually hidden with css display: none, and then a css ::before pseudo element is used to insert an image of a checked or unchecked box (probably to make checkboxes look consistent across all browsers). Because of this you can't just check the checkbox, instead you can click on the label for the checkbox. In this case either of the following should do that
find(:css, 'label', text: 'Ik accepteer de accountvoorwaarden').click
find(:css, 'label[for="RegisterUserFullEmail_Accepted-1"]').click
since in this case the label has a link inside it which appears to be at the middle of the link (where it would get clicked) we can look at what else is in the label and there is a separate span element in it which we can click on without clicking on the link so
find(:css, 'label', text: 'Ik accepteer de accountvoorwaarden').find(:css, 'span').click
find(:css, 'label[for="RegisterUserFullEmail_Accepted-1"] span').click
Upvotes: 1