Re: Submitting a form with two identically named fields using WWW::Mech

"Peteris Krumins [Newsgroups]" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.lwp
Message-ID <[email protected]>
Andy Lester wrote:

> On May 16, 2007, at 3:46 PM, Peteris Krumins [Newsgroups] wrote:
>
>> Now if I call Mech's submit_form() and specify both fields, the  Mech 
>> would die with the following error:
>> "Illegal value 'false' for field 'element_name' at Mechanize.pm  line 
>> ..."
>
>
> Can you give a specific code snippet that fails?  It would let me  
> make a test out of it, and make everything clear to all reading  
> (including me).


I am writing a script which will automatize form submission on some 
websites.
There is a video sharing website www.bolt.com which has a registration 
form with two elements named 'signupMe' - a text field and checkbox.
The text field has default value "false" and the checkbox has a default 
value "on".

Here it is an example which will cause Mech to die:

#!/usr/bin/perl

use strict;
use warnings;

use WWW::Mechanize;

my $mech = WWW::Mechanize->new;

$mech->get('http://www.bolt.com/registration/index.bt');
$mech->submit_form(
    with_fields =>  {
        signupMe    =>  "on",
        signupMe    =>  "false",
    }
);


I'd like Mech not to die and rather figure out which value belongs to 
which type of field (text field or checkbox) and just
submit both of them in order they appear in the form as FireFox does.


P.Krumins
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.