in reply to WWW::Mechanize with forms

Hmmm ... i set up this test CGI script:
use strict; use warnings; use CGI qw(:standard); print header(), start_html(), start_form(), textfield('new_primer_type'), submit('submit'), end_form(), end_html(), ; if (param('submit')) { print hr, p('You submitted ', param('new_primer_type')) ; }
Over at http://unlocalhost.com/cgi-bin/script.cgi. Then i ran this W::M test script:
use strict; use warnings; use WWW::Mechanize; my $mech = WWW::Mechanize->new(); my $url = 'http://unlocalhost.com/cgi-bin/script.cgi'; $mech->get($url); die "Couldn't get page\n" unless $mech->success; $mech->form_number(1); die "Couldn't set form\n" unless $mech->success; $mech->field('new_primer_type', 'dummy1'); die "Couldn't set type\n" unless $mech->success; $mech->click('submit'); die "Couldn't click submit\n" unless $mech->success;
And it never died ... note that even though i made both of your original scripts more 'idiomatic', the results are still the same. The only thing that i changed that might matter is the action destination of the CGI script. The reason why i did so, should be apparent, but as for what is causing your problem, i can't say ...

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: WWW::Mechanize with forms
by Anonymous Monk on Sep 22, 2003 at 22:02 UTC

    Well, that sorta solves it: running the exact test script on my machine generates:

    C:\dev>perl -w testCGI.pl Unexpected field value http://unlocalhost.com/cgi-bin/script.cgi at (e +val 5) line 1

    I'm on Windows XP, Perl 5.6.1, and WWW::Mechanize 0.48. I'll have to test another couple of machines to see where the problem lies. Would you mind terribly keeping that script available for a couple of hours? I'd much appreciate the ability to validate against two servers rather than just one.

      Sure, i'll leave that CGI script for the rest of the day/night.

      I tested with WWW::Mechanize versions 0.55 and the latest, 0.59 - you might need to upgrade.

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)