Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: HTTP::Form and invalid radio button values

by cees (Curate)
on Dec 19, 2003 at 16:11 UTC ( [id://315823]=note: print w/replies, xml ) Need Help??


in reply to HTTP::Form and invalid radio button values

Just finishing up this thread in case someone else runs into this same issue. It turns out that WWW::Mechanize allows you to build and use your own HTTP::Request object through the use of the $a->request( $request ); method. This bypasses the need for HTML::Form, and allows you to enter any information into the form fields.

Here is a code snippet that shows how it can work:

use Test::More qw(no_plan); use WWW::Mechanize; use HTTP::Request::Common; my $url = 'http://starting.url/'; my $a = WWW::Mechanize->new(); isa_ok( $a, "WWW::Mechanize" ) or die; $a->get( $url ); is( $a->status, 200, 'Fetched OK' ); my $form = $a->form_name('details'); ok($form, 'Details form'); my $action = $form->action(); # build a request object my $request = HTTP::Request::Common::POST($action, [ a_radio_button => 'invalid_value', ]); # Add any cookies into the request object $a->cookie_jar->add_cookie_header( $request ); # make the request $a->request( $request ); is( $a->status, 200, 'Fetched OK' );

Thanks for the help and suggestions

- Cees

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://315823]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 15:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found