[英]Perl Fill Out Form Based on Element ID
I am trying to use WWW::Mechanize
to fill out a form. 我正在尝试使用
WWW::Mechanize
填写表格。 Unfortunately my page requires JS so I am now using WWW::Mechanize::Firefox
. 不幸的是,我的页面需要JS,所以我现在正在使用
WWW::Mechanize::Firefox
。
Here is the element I am trying to fill out. 这是我要填写的元素。
<input id="ember745" class="ssTextboxField"></input>
The set_field() function takes an element name. set_field()函数采用元素名称。 How would I give it an element ID (ember 745) and have it fill the form in?
如何给它一个元素ID(Ember 745)并填写表格?
Here is my code so far 到目前为止,这是我的代码
use WWW::Mechanize::Firefox;
my $mech = WWW::Mechanize::Firefox->new(autoclose => 0);
$mech->get(URL);
$mech->form_number(1);
$mech->submit_form(
fields => {
ember745 => $value
});
Figured it out, had to use a selector 想通了,不得不使用选择器
my $field = $mech->selector('input.ssTextboxField', single => 1);
$mech->field( $field => $value );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.