Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

field method for Win32::IE::Mechanize
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

Report this thread to moderator Post Follow-up to this message
Old Post
fdl
12-20-04 08:56 PM


Re: field method for Win32::IE::Mechanize
quote:
Originally posted by fdl $loginform->field("user",'some user was here'); $loginform->field("password",'some password was here');
Hm, Appearently, It should have been $ie->field... Modules, not my favority cup of tea Filip

Report this thread to moderator Post Follow-up to this message
Old Post
fdl
12-23-04 03:15 PM


Re: field method for Win32::IE::Mechanize
<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



Report this thread to moderator Post Follow-up to this message
Old Post
JayEs
12-29-04 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Modules archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 08:09 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.