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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|