For various reasons, I am trying to use Perl to drive Internet Explorer as a user agent for testing a webserver. I am using this in apposition (note:
apposition, not
opposition) to LWP::UserAgent for several reasons. I am trying to build up a toolkit of overlapping technologies.
It has been suggested to me that this might be a good thing to do if there is a lot of Javascript involved (and there is), moreover I am finding that driving IE this way has gotten me around whatever problems are slowing me down in LWP::UserAgent. Sure, I should learn how to use LWP::UserAgent better, but this is a tactical situation.
Microsoft describes their interface for a method called Navigate:
object.Navigate( _
url As String, _
[Flags As Variant,] _
[TargetFrameName As Variant,] _
[PostData As Variant,] _
[Headers As Variant])
I have used this joyfully so far, but only with the first param, which is the URL. So, now I now need to use the PostData and Headers, and am having only sorrow in using anything beyond the first param. I thought it might have been some kind of lost-in-translation from VBA to Perl. I looked at
perldoc Win32::OLE
which says:
$ex->Amethod("arg")->Bmethod->{'Property'} = "foo";
$ex->Cmethod(undef,undef,$Arg3);
$ex->Dmethod($RequiredArg1, {NamedArg1 => $Value1, NamedArg2 => $Value
+2});
The program below illustrates my problem. When I try to use the first method, I believe I am passing everything as a GET. This does work, and takes me to the socks search results to dwell there 5 seconds. The other two instances seem like they should work too, one via positional parameters and the other via named parameter, for 5 seconds each. Alas, they take me to our 404 handling page, where a pained-looking woman expresses her displeasure at my attempt.
use Win32::OLE qw(EVENTS);
use strict;
my $IE = Win32::OLE->new("InternetExplorer.Application")
|| die "Could not start Internet Explorer.Application\n";
$IE->{visible} = 1;
$IE->Navigate("http://amos.shop.com/amos/cc/main/ccn_search/ccsyn/150/
+stid/6150608?search_form=&st=socks&sy=products&search_button.x=39&sea
+rch_button.y=12");
sleep 5;
$IE->Navigate("http://amos.shop.com/amos/cc/main/ccn_search/ccsyn/150/
+stid/6150608", undef, undef, "search_form=&st=socks&sy=products&searc
+h_button.x=39&search_button.y=12", undef);
sleep 5;;
$IE->Navigate("http://amos.shop.com/amos/cc/main/ccn_search/ccsyn/150/
+stid/6150608", {PostData=>"search_form=&st=socks&sy=products&search_b
+utton.x=39&search_button.y=12"});
sleep 5;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.