Hi,
In the testing script below I can't seem to set values in a multiple
select list with WWW::Mechanize.
I tired several different methods of setting the fields but none have
worked.
In the form below you should be able to select one or more city and one or
more county. After removing the multiple option in the county select, I
was able to set the field (ie test 4 started working).
Thanks in advance for any advice, or suggestions.
Jim
Here is the test script (with the actual url replaced with localhost):
use strict;
use Test::More;
use WWW::Mechanize;
BEGIN { plan tests = 5}
my $url=qq|http://localhost/test1.html|;
ok(my $a = WWW::Mechanize-new(),create browser);
$a-timeout(10);
$a-get($url);
is($a-status,200,get initial page ($url));
ok($a-form_number('1') ,select query form);
ok($a-field('county_all'=1),set county_all to 1);
#print contents:,$a-content,\n;
ok($a-field('nid' = '106'),set nid to 106);
And here is the html file test1.html :
!DOCTYPE html PUBLIC -//W3C//DTD HTML 4.01 Transitional//EN
html lang=en
headtitleTest/title
meta http-equiv=Content-Type content=text/html; charset=iso-8859-1
/head
body
form method=get action=http://localhost/summary/;
pPick one or more city/p
select name=nid size=6 multiple=multiple
option value=106foo city/option
option value=199bar city/option
/select
pPick a county/p
!-- select name=county_all size=6 multiple=multiple --
select name=county_all size=6
option value=1Bay/option
option value=2Washington/option
/select
input type=submit name=done value=done
input type=hidden name=action value=get_indicators
/form/body/html
Here is the output of my testing script listed above:
1..5
ok 1 - create browser
ok 2 - get initial page (http://localhost/test1.html)
ok 3 - select query form
ok 4 - set county_all to 1
not ok 5 - set nid to 106
# Failed test (test1.pl at line 20)
# Looks like you failed 1 tests of 5.
An archive search shows someone (ask) asking a similar question about
HTML::Form but the single response didn't make sense to me.
trouble with SELECT inputs in HTML::Form
http://www.mail-archive.com/[EMAIL PROTECTED]/msg04154.html