i am building a crawler and i am using Mechanize. I wish to click on a radio button. How do i do that ?
Like for example there are two radio buttons say 'A' and 'B'. The website automatically selects B, but i want 'A' using Mechanize in ruby. I am also using the latest version on Mechanize.
There are a couple of ways to do this. Probably the best would be to use the radio button's name
or id
:
form.radiobutton_with(:name => /b/).check
You could also do something like this:
form.radiobuttons.first.check
Which is more succinct, but more likely to break (if for instance you were to change the design of your form).
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