Hi Toshiro,
Toshiro (mailing lists) wrote:
Get the form object. perldoc HTML::Form. Look for action() method.
Figure out what the JavaScript would set the action to. Set it to that.
There's an easier way. Get Firefox 1.5 and the TamperData plug-in
(doesn't work with the 2.0 Beta). Activate the TamperData window. Load
the desired page and submit the form. Look at the log generated by
Tamper Data. It's all there.
I've been trying to do what you suggested, but I don't know how to use
Mech and HTML::Form together,
Try the following...
$action="whatever";
# initialize other variables as appropriate....
$form = $mech->form_name($formname); # one of several methods which
return a form.
if (!$form) {
# error processing
}
$mech->field($targetField,$targetValue); # user your fieldnames and
values here...
$mech->field($usernameField,$userName);
$mech->field($passwordField,$passWord;
$form->action ( $action );
$mech->click();
The above will work if the form is already defined. Sometimes javascript
defines the form on the fly. In which case, try this:
my $f = HTML::Form->parse(<<EOT, $loginpage );
<form>
<input name="min" value="$cell">
<input name="target" value="Login">
<input name="action" value="doLogin">
<input name="userid" value="$userId">
<input name="password" value="$pswd">
</form>
EOT
$f->method ( "POST" ) ;
$mech->get( $homepage );
$mech->{forms} = ( $f ) ;
$mech->{form} = $f ;
$mech->submit();
Not really sure if these last few lines are kosher, but they worked ;-)
Cheers
Peter