简体   繁体   English

WWW :: Mechanize :: Firefox单击或从选择中选择一个选项?

[英]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.

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