简体   繁体   中英

How do I use WWW::Mechanize to check a radio box?

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?

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM