Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Howdy monks,
Last week I was advised to look into WWW::Mechanize for automating testing of a CGI website. I started to try to take that good advice today, but ran into a roadblock. I think the block is with forms, but even now that I have the test-case down to something small I can't really see where the error is. The CGI page is:
use CGI; use strict; my $cgi = new CGI; print $cgi->header(), $cgi->start_html(), $cgi->start_form({ -method => 'GET', -action => 'PUNS_addprimers_execute.cgi' }), $cgi->textfield('new_primer_type'), $cgi->submit('submit'), $cgi->end_form(), $cgi->end_html();
Meanwhile I try to automate access to this via:
use WWW::Mechanize; use strict; my $mech = WWW::Mechanize->new(); my $url = 'http://x.x.x.x/cgi-bin/script.cgi; $mech->get($url); if (!$mech->success()) { die "Couldn't get page\n"; } $mech->form_number(1); if (!$mech->success()) { die "Couldn't set form\n"; } $mech->field('new_primer_type', 'dummy1'); if (!$mech->success()) { die "Couldn't set type\n"; } $mech->click('submit');
And this dies with the error message:
Unexpected field value http://x.x.x.x/cgi-bin/script.cgi at (eval 5) l +ine 1
I'm stuck: this seems like a straight-forward test-case. Any ideas what I'm doing wrong?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: WWW::Mechanize with forms
by jeffa (Bishop) on Sep 22, 2003 at 21:49 UTC | |
by Anonymous Monk on Sep 22, 2003 at 22:02 UTC | |
by jeffa (Bishop) on Sep 22, 2003 at 22:28 UTC | |
|
Re: WWW::Mechanize with forms (SOLVED: Thanks Jeffa)
by Anonymous Monk on Sep 23, 2003 at 00:42 UTC |