[英]WWW::Mechanize::Firefox clicking or selecting an option from a select?
How do you click or select an option in a select
using WWW::Mechanize::Firefox
. 你如何单击或者选择在一个选项
select
使用WWW::Mechanize::Firefox
。 The select
is within a form
in this case. 在这种情况下,
select
是在一个form
内。
Code follows: 代码如下:
<form name="formo">
<select class="selectc" onchange="go()" name="selecto">
<option value="">Option 1</option>
<option value="">Option 2</option>
<option value="?place1">Option 3</option>
<option value="?place2">Option 4</option>
I would like to click Option 3 to go to place1, for example. 例如,我想点击选项3转到place1。
You have to use $mech->select
like this: 你必须使用
$mech->select
这样:
$mech->select( 'selecto', '?place1' );
The first parameter is the name of the select
element, the second is the value you want to set it to. 第一个参数是
select
元素的名称,第二个参数是您要将其设置为的值。 That value has to be one of the option
s inside the select
. 该值必须是
select
中的option
之一。 See the docs for more info. 有关详细信息,请参阅文档 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.