From the following html how can i choose the second radio button .In the page load first radio button is selected when i use the following code
page.choose('#PPRINT')
<div id="printOpns" class="span6">
<div class="row"> <div class="span2" align="center">
<input id="Print" class="radio" type="radio" checked="" value="EPrint" name="printO"></div>
</div>
<div class="row"><div class="span2" align="center">
<input id="PPRINT" class="radio" type="radio" value="FPrint" name="printO">
</div>
</div>
</div>
Only one radio button in a given group can be selected at the same time.
This means that you have two radio groups, each containing one radio button. You need to put them in the same group (by making them share a name) if you only want one of them to be selected.
To label a radio button, add a <label> element after the <input> element and insert a for attribute with the same value as the id of the associated <input> element. Then, write your label text in the <label> tag. While using <label> isn't strictly necessary, it's considered a best practice for two reasons.
The Capybara API for the choose method says "Find a radio button and mark it as checked. The radio button can be found via name, id or label text." This means that the text that is supplied to the choose
method must match the name, id or label of the radio button.
choose
does not support css-selectors. Therefore, when you do:
page.choose('#PPRINT')
Capybara is looking for a name, id or label that equals "#PPRINT".
You want to do (ie no "#"):
page.choose('PPRINT')
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