I am writing a Perl script to test certain parts of my webpage as I make changes to it. Using the WWW::Mechanize class, how can I select a radio box and submit a form?
+5
A:
What have you tried already? Did you check the WWW::Mechanize docs?
To set a field:
$mech->set_fields('radio_group_name' => 'option');
Remember, radio buttons are just instructions to the browser on how to interact with the form widget. Ultimately, it's all just fields and values you send to the web server.
To submit a form, you use one of these methods, depending on what you are trying to do:
$mech->click_button( ... );
$mech->submit();
$mech->submit_form( ... );
It does look like there's a ticket in Google Code to provide some better examples though.
brian d foy
2010-09-23 20:17:24