WWW::Mechanize::FormFiller(3pm) | User Contributed Perl Documentation | WWW::Mechanize::FormFiller(3pm) |
WWW::Mechanize::FormFiller - framework to automate HTML forms
Form fields can be specified by name or by a regular expression. A field specified by name takes precedence over a matching regular expression.
You are not limited to fixed form values - callbacks and interactive editing are also already provided :
# Create a form filler that asks us for the password # Normally, the HTML would come from a LWP::UserAgent request my $html = "<html><body><form name='f' action='/login.asp'> <input type='text' name='login'> <input type='password' name='password' > <input type='submit' name=Login value='Log in'> <input type='hidden' name='session' value='0xDEADBEEF' /> </form></body></html>"; my $f = WWW::Mechanize::FormFiller->new(); my $form = HTML::Form->parse($html,"http://www.fbi.gov/super/secret/"); $f->add_filler( password => Interactive => []); $f->fill_form($form); my $request = $form->click("Login"); # Now we have a complete HTTP request, which we can hand off to # LWP::UserAgent or (preferrably) WWW::Mechanize print $request->as_string;
The module is intended as a simple way to fill out HTML forms from a set of predetermined values. You set up the form filler with value elements, retrieve the HTML form, and let the form filler loose on that form.
There are value classes provided for many tasks - fixed values, values to be queried interactively from the user, values taken randomly from a list of values and values specified through a callback to some Perl code.
Example :
$filler = WWW::Mechanize::FormFiller->new(); $filler->fillout( # For the the simple case, assumed 'Fixed' class, name => 'Mark', # With an array reference, create and fill with the right kind of object. widget_id => [ 'Random', (1..5) ], );
$filler = WWW::Mechanize::FormFiller->new(); $filler->fillout( # If the first parameter isa HTML::Form, it is # filled out directly $form, name => 'Mark', motto => [ 'Random::Word', size => 5 ], );
# This works as a direct constructor as well WWW::Mechanize::FormFiller->fillout( $form2, name => 'Mark', motto => [ 'Random::Word', size => 5 ], );
The following WWW::Mechanize::FormFiller::Value subclasses are currently distributed :
None by default.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
Copyright (C) 2002,2003 Max Maischein
Max Maischein, <corion@cpan.org>
Please contact me if you find bugs or otherwise improve the module. More tests are also very welcome !
Bug reports are best done via RT at https://rt.cpan.org
WWW::Mechanize,WWW::Mechanize::Shell,WWW::Mechanize::FormFiller::Value
2017-01-21 | perl v5.24.1 |