1

我收到一个错误No form defined at cqSubmitter.pl at line 33,这是第二种set_fields方法。其他时候我得到一个Error POSTing http://micron.com Internal Server Error at line 39,它对应于最后click_button一行。

我不太确定发生了什么,为什么它说没有定义形式?包含第click_button一种方法的代码的前半部分工作正常并保存了正确的页面,但是当我set_fields第二次尝试时,它会出错。

任何熟悉 Mechanize 包的人都知道这里发生了什么?

use Data::Dumper;
use HTTP::Request::Common qw(GET);
use WWW::Mechanize;


#Prepopulated information
my $types_ = "";
my $dept_ = "";
my $group_ = "";


#Create new WWW::Mechanize object
my $mech = WWW::Mechanize->new( 'ssl_opts' => { 'verify_hostname' => 0 } );
my $url = "http://f2prbrequest";

#Fetch URL or Die Tryin'
$mech ->get($url);

$fname = "user";
$pswd = "password";


#Login to ClearQuest form using credentials
$mech->set_fields(
    USER => $fname
   ,PASSWORD => $pswd
);


$mech->click_button(
   name => 'Submit'
 );


#Set fields and actually fill out ClearQuest Form
$mech->set_fields(
    types => $types_
   ,dept => $dept_
   ,group => $group_
  );


$mech->click_button(
    name => 'submit1'
 );

$mech->save_content("clearQuestFilled.html");
4

0 回答 0