Perl-Mechanize发布隐藏的表单值

时间:2014-06-27 16:05:30

标签: perl mechanize hidden-field

我正在尝试创建一个perl脚本来为我测试Web表单。我正在使用机械化进行自动化,并且无法在现场方法上查找文档。我使用field方法返回隐藏表单的值,这导致我的帖子失败。问题可能是一个简单的疏忽,但我对$mech->field('name');感到好奇,因为它似乎正在为我恢复隐藏形式的价值。

Using perl v5.16.3(w& w / o警告)

$id = $test->field('MId');  
print $id . " \n"; 
          #This is printing the desired Id ,
          #the post will  not succeed as long as $id assigned this way. 

print "This is where I am attempting to upload the images\n";
my $fileuploadresult;
$fileuploadresult = $mech->post($uploadURL,
    'Content_Type' => "multipart/form-data",
    'Content' => [
    'myFile' => $file , 'MId' => $id
    ]
    );
print $fileuploadresult->content() . "\n\n\n"; #If I set $id to something like 'test' it
#will work fine.
#I am using two agent because there are two POST's going on and they have to be sequential.

当我抓住表格的价值时,我想知道为什么我的提交失败了。我刚刚更改了'字段'价值的方法'并意识到这解决了我的问题。抱歉,noob问题没有充分查看文档。当字段返回我认为是其功能的一部分的值时,我没有意识到它也将值设置为null。 (或者据我所知,这就是它的作用)

0 个答案:

没有答案