简体   繁体   English

如何使用WWW :: Mechanize检查收音机盒?

[英]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. 我正在编写一个Perl脚本来测试我的网页的某些部分,因为我对其进行了更改。 Using the WWW::Mechanize class, how can I select a radio box and submit a form? 使用WWW :: Mechanize类,如何选择一个单选框并提交表单?

What have you tried already? 你有什么尝试? Did you check the WWW::Mechanize docs? 你检查过WWW :: Mechanize文档了吗?

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. 最终,它只是您发送到Web服务器的字段和值。

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 . 看起来谷歌代码中一张票可以提供一些更好的例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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