Code Comments
Programming Forum and web based access to our favorite programming groups.
Hello,
I'm trying to execute the following (still incomplete) script:
use strict;
use Win32::IE::Mechanize;
my $ie = Win32::IE::Mechanize->new(visible=>1);
$ie->get("something was here but is removed for security reasons");
sleep 1;
my $webpagetext = "nothing yet";
$webpagetext = $ie->content(format=>"text");
my @webforms = $ie->forms;
my $webformstotal = @webforms;
print "number of forms found = $webformstotal\n";
print "webform : $webforms[0]\n";
my $loginform = $ie->current_form;
print "loginform : $loginform\n";
$loginform->field("user",'some user was here');
$loginform->field("password",'some password was here');
but I'm getting the error code :
"Can't locate object method "field" via package "Win32::IE::Form" at
testweb.pl"
Does anyone have any idea what this beginner is doing (stupidly)
wrong?
Thanks in advance,
Filip
--
fdl
Post Follow-up to this messagequote:Hm, Appearently, It should have been $ie->field... Modules, not my favority cup of tea Filip
Originally posted by fdl $loginform->field("user",'some user was here'); $loginform->field("password",'some password was here');
Post Follow-up to this message<SNIP>
> sleep 1;
Nothing to do with your question, but the sleep is not needed. IE::Mecahnize
waits until all requests are completed anyway (at least that is my
experience).
> my $webpagetext = "nothing yet";
Again, not relevant to the question, but this can be rewritten as:
my $webpagetext;
No need to assign anything, or faster yet:
my $webpagetext = $ie->content(format=>"text");
> my $loginform = $ie->current_form;
> print "loginform : $loginform\n";
>
> $loginform->field("user",'some user was here');
current_form is a "status" method. It returns the current form, but I don't
think it actually does anything with it. I have only limited experience with
IE::Mech, but I think what is going wrong is that you are not telling the
script which form on the page to use, or not correctly anyway. Instead I
think you should use: form_name (or if the form doesn't have a name:
form_number).
What has always worked for me is:
(some code omitted)
my $ie = Win32::IE::Mechanize->new( visible => 1);
$ie->get($url);
$ie->form_name("some name here");
$ie->field("some field", 'some value');
Also you probably don't need all the extra variables if all you are doing is
trying to fill out a simple login form. You can get rid of $loginform,
@webforms and $webformstotal
Try that and see if it helps you out any....
JS
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.