The html for Option 1 looks like:
<label class="control-label" for="__Option:0x000001061be660_">Option 1</label>
<div class="controls">
<input id="options_" name="options[]" type="checkbox" value="1" />
</div>
The problem is that the label and checkbox are not properly associated with each other:
- The label has a
for
attribute of "__Option:0x000001061be660_" - The checkbox has an
id
attribute of "options_"
As a result, Capybara finds the label "Option 1", but not one that is associated to a checkbox.
The page needs to be updated so that the label for
attribute and checkbox id
attribute match. For example:
<label class="control-label" for="__Option:0x000001061be660_">Option 1</label>
<div class="controls">
<input id="__Option:0x000001061be660_" name="options[]" type="checkbox" value="1" />
</div>