use Win32::OLE;
use Win32::SAM;
#use Win32::Slingshot;
$| = 1;
my $URL = "http://www.google.com/";
my $seconds;
$Win32::OLE::Warn = 3;
StartIE();
$seconds = Navigate($URL);
print "Google Page took $seconds seconds to load\n";
SetEditBox("q","Presidents");
$seconds = ClickFormButton("btnG");
print "Query Page took $seconds seconds to load\n";
Going through the code line by line...
$seconds = Navigate($URL);
This the second line of code that makes a subroutine call to Win32::SAM.pm. The Navigate subroutine is defined in SAM.pm which lives here:
c:\perl\site\lib\win32\SAM.pm
It is defined there like this:
sub Navigate { #$URL,$popup
my ($URL,$popup) = @_;
#print "popup = $popup\n";
$popup eq "popup" ? ($popup = 1) : ($popup = 0) if (defined($popup));
my $seconds = 0;
$IE->navigate($URL);
my $hnd = $Win32::SAM::IE->{HWND};
if ($popup) {
#print "Calling
WaitForDocumentCompleteForPopup() popup = $popup\n";
$seconds =
WaitForDocumentCompleteForPopup();
}
else {
#print "Calling
WaitForDocumentComplete()\n";
$seconds = WaitForDocumentComplete();
return $seconds;
#print "Here's the Window handle: $hnd\n";
}
}
This subroutine tells Internet Explorer to Navigate to the scalar $URL.
It takes an optional Boolean Parameter $popup.
This parameter should be set to 1 if the URL you are navigating to raises one or
more popup windows.
The Navigate Subroutine returns the number of seconds that Internet Explorer took to load the URL.