CHECK
<div class="checkbox"> <input id="yes_1212" class="check_uncheck" type="checkbox" value="true" name="yes" checked="checked"> <label></label> </div>
UNCHECK
<div class="checkbox "> <input id="allow__100" class="check_uncheck" type="checkbox" value="false" name="Allow"> <label></label> </div>
how to check whether the check box is checked or not
There are multiple ways depending on exactly what you're trying to do - if you've already found the element and just want to know whether or not it's checked you can do something like
element = find('#yes_1212') ... element.checked?
If you're trying to assert that the box is on the page and is checked/unchecked you could do
expect(page).to have_field('yes_1212', checked: true) # checked: false or unchecked: true for not checked
or
expect(page).to have_checked_field('yes_1212') # or have_unchecked_field
If you want a boolean response and don't already have a reference to the element
page.has_field?('allow__100', unchecked: true) page.has_unchecked_field?('allow_100')
In all cases if the input element is actually non-visible for styling reasons you can pass visible: false
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