Below is the html code for two radio buttons, they only differ by "value" attribute
<input id="AmountOption" name="AmountOption" type="radio" value="1">
<input id="AmountOption" name="AmountOption" type="radio" value="2">
What Im trying to do is to choose the radio button with "value =2 "
I tried using "choose("AmountOption")" which choses the first radio button, but i want to choose the second radio button
How can i achieve this with "choose("")" method provided by capybara.
Any other alternatives are also welcome.
Thanks in Advance
Look at implementation of choose:
def choose(locator, options={})
find(:radio_button, locator, options).set(true)
end
So it's obvious that you should invoke method set on some element.
:radiobutton selector supports only id, name and label so you can't use it and should use some other selector type:
find('#AmountOption[value=2]').set(true) # selector type is :css by default
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