Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the WWW-Mechanize CPAN distribution.

Report information
The Basics
Id: 19034
Status: resolved
Priority: 0/
Queue: WWW-Mechanize

People
Owner: Nobody in particular
Requestors: mschwern [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.18
Fixed in: (no value)



Subject: Problems filling out <select multiple>
HTML::Form->value has trouble handling <select multiple> (see http://rt.cpan.org/Ticket/Display.html?id=18962). This in turn gives WWW::Mechanize trouble. Attached is a test which demonstrates the problem (place it in t/local). By having Mechanize use HTML::Form->param the problem can be worked around but I don't know if this is a good idea for all form values. Its an HTML::Form bug but Mechanize should be aware of the problem.
Subject: select_multiple.t
#!perl use strict; use Test::More 'no_plan'; use lib 't/local'; use LocalServer; use HTTP::Daemon; use HTTP::Response; BEGIN { use_ok( 'WWW::Mechanize' ); delete @ENV{ qw( http_proxy HTTP_PROXY ) }; delete @ENV{ qw( IFS CDPATH ENV BASH_ENV ) }; } my $mech = WWW::Mechanize->new(cookie_jar => {}); isa_ok( $mech, "WWW::Mechanize" ); ok(defined($mech->cookie_jar()), 'this $mech starts with a cookie jar'); my $html = <<'HTML'; <html> <head><title>%s</title></head> <body>Whatever. <form action="foo.thing"> <select name="chanId" MULTIPLE> <option value="130" selected>Anime Network</option> <option value="119" >COM 250</option> </select> </form> </body> </html> HTML my $server = LocalServer->spawn( html => $html ); isa_ok( $server, "LocalServer" ); $mech->get($server->url); ok( $mech->success, 'Fetched OK' ); # This fails because HTML::Form->value cannot handle <select multiple> (see rt.cpan.org 18962) eval { $mech->submit_form( form_number => 1, fields => { chanId => 119, } ); }; is( $@, '' ); # Same problem as above. eval { $mech->form_number(1); $mech->set_fields( chanId => 119, ); }; is( $@, '' ); # This fails because HTML::Form represents a <select multiple> as many input objects, not one. eval { $mech->submit_form( form_number => 1, fields => { chanId => [119], } ); }; is( $@, '' ); # This fails because field() calls HTML::Form->value(), same problem as above. eval { $mech->form_number(1); $mech->field( chanId => 119, ); $mech->submit; }; is( $@, '' ); # This works because it happens to use HTML::Form->param() and that happens to work with # <select multiple> eval { $mech->form_number(1); $mech->field( chanId => [119], ); $mech->submit; }; is( $@, '' ); # This works because 130 is the first value in the <select multiple> eval { $mech->submit_form( form_number => 1, fields => { chanId => 130, } ); }; is( $@, '' ); SKIP: { eval "use Test::Memory::Cycle"; skip "Test::Memory::Cycle not installed", 1 if $@; memory_cycle_ok( $mech, "No memory cycles found" ); }