in reply to Re: click radio button with WWW::Mechanize
in thread click radio button with WWW::Mechanize
I just found this very old node by doing some searches on PM regarding a similar problem with mechanize.
Funny thing is, that whilst the answer above does address the issue at hand (and also proves the laziness of people towards searching before asking), none of the listed nodes above actually provide any clear and simple answer as to the questions posted by any of the OPs!
Anyway, I found it quite funny and peculiar, so here is the clear and simple answer:
In WWW::Mechanize radio buttons can be set just like you would set any regular text input field, but you must know the exact value of the radio button you want to select beforehand. They don't work like selects and they don't work by clicking. See examples below:
# this 'clicks' the $rb_value button in rb_name group $mech->set_fields( rb_name => $rb_value, ); # this will work as well $mech->submit_form( form_number => 1, fields => { rb_name => $rb_value, }, );
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: click radio button with WWW::Mechanize
by Anonymous Monk on Apr 21, 2011 at 13:02 UTC | |
Here is how I test these things
| [reply] [d/l] |
by Aldebaran (Curate) on Jun 19, 2015 at 00:44 UTC | |
I found this thread with a google search for "perl WWW::Mechanize radiobutton examples." I always read the ones for perlmonks first and found the links to other sources unhelpful. Using the syntax from above, I was able to use WWW::Mechanize to select a radio button, and supply a text with data that populates a new guess on the time at which the event I'm looking for is to occur. That event, btw, is the conjunction of venus and jupiter, which will happen in somewhere around 2 weeks from the writing of this node (6-18-15). I'm using John Walker's Fourmilab site and perl to determine when this will happen exactly. Walker's site makes a good guinea pig for WWW::Mechanize for several reasons, but let me name a few. This script will produce the same output in a time-invariant fashion. The html isn't written by a machine that cares nothing for legibility. There's no splash screens, adware, flash videos, or similar pests. One can easily change these values and focus on new astronomic events. My script:
Output:
I've already thanked the monks who wrote this thread in the form of my upvote, but I'd also like to thank all those who help me indulge my twin hobbies of skywatching and perl. | [reply] [d/l] [select] |