T has asked for the wisdom of the Perl Monks concerning the following question:

Hi, I am currently working at the script which would login to new bugzilla 2.23 and do the other things, but I just stuck at the beggining, I am using www::mechanize to do these things, my script looks like this:
#!/usr/bin/perl use WWW::Mechanize; my $link = "https://localhost/query.cgi?GoAheadAndLogIn=1"; my $login = "x\@gx.com"; my $pass = "xx"; my $mech = WWW::Mechanize->new(); $mech->agent_alias( 'Windows IE 6' ); $mech->get( $link ); my %login = ( "Bugzilla_login"=> $login, "Bugzilla_password"=> $pass); $mech->set_fields(%login); $mech->click( 'GoAheadAndLogIn' );
# ./bug.pl No such field 'Bugzilla_password' at /usr/lib/perl5/site_perl/5.8.8/WW +W/Mechanize.pm line 1265
And the problem is that www::mechanize cannot found form called Bugzilla_password, but Bugzilla_login finds with no problem, can you suggest what might be wrong ?

Replies are listed 'Best First'.
Re: Login to new bugzilla
by Fletch (Bishop) on Apr 03, 2007 at 21:37 UTC

    Run the mech-dump utility that installs with WWW::Mechanize and see what that says the fields are.

    $ mech-dump http://perlmonks.org/ GET http://perlmonks.org/? node= (text) <NONAME>=Search (submit) POST http://perlmonks.org/? [login] node_id=131 (hidden readonly) op=login (hidden readonly) user= (text) passwd= (password) expires=<UNDEF> (checkbox) [*<UNDEF>/off|+10y/remembe +r me] login=Login (submit) POST http://perlmonks.org/? node_id=131 (hidden readonly) foo=Refresh (submit) POST http://perlmonks.org/? displaytype=display (hidden readonly) node_id=607758 (hidden readonly) vote=0 (radio) [*0/obsessively|1/often|2/ +infrequently|3/-ged, but I quit|4/I'm tempted to|5/I never considered + it|6/I can't imagine doing that|7/What's "blog"?] <NONAME>=Vote (submit)
      I used the mech-dump utility as You suggested, and it showed the forms which I would like to use:
      % mech-dump "https://localhost/query.cgi?GoAheadAndLogIn=1" GET https://localhost/buglist.cgi quicksearch= (text) <NONAME>=Find (submit) POST https://localhost/query.cgi [login] Bugzilla_login= (text) Bugzilla_password= (password) GoAheadAndLogIn=1 (hidden readonly) GoAheadAndLogIn=Log in (submit) GET https://localhost/token.cgi a=reqpw (hidden readonly) loginname= (text) <NONAME>=Submit Request (submit) GET https://localhost/buglist.cgi quicksearch= (text) <NONAME>=Find (submit)
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: Login to new bugzilla
by roboticus (Chancellor) on Apr 03, 2007 at 21:20 UTC
    Perhaps you may want to dump the HTML of the page to be certain of your field names?

    Also, just because it reported the error on field 'Bugzilla_password', that doesn't mean that it accepted 'Bugzilla_login'. Since you're passing set_fields a hash, there are no guarantees about the order that set_fields will get them out of the hash.

    ...roboticus