Killing an WIN32OLE IE Object

I’ve written a nifty little script that loads a list of URLs in IE, and
times how long it takes to download and render them (and all their
images). There are two ways to do this, spawn a new IE for every link,
or reuse the same IE.

If I spawn a new IE every time, the IE that I call #Quit on doesn’t
die until the script terminates, which seems to cause OLE runtime
errors about invoking a synchronous call before an asynchronous one
completes (in navigate()). If I sleep, then IE freezes also, so
I’m left with just retrying until I get lucky.

If I reuse the same IE every time, the cache never seems to get
cleared, so the page load time ends up being totally bogus. (I’m
guessing IE doesn’t release all of its filehandles…)

To get to the point, how can I force a WIN32OLE object to wait until a
method completes properly? (specifically ie.quit)

···


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

On further investigation, IE only freezes when using WIN32OLE_EVENT. So
to ammend this, how can I get accurate page load times without using
WIN32OLE_EVENT?

(tracking #ReadyState, or #StatusText comes to mind, any other ideas?)

···

Eric Hodel (drbrain@segment7.net) wrote:

If I spawn a new IE every time, the IE that I call #Quit on doesn’t
die until the script terminates, which seems to cause OLE runtime
errors about invoking a synchronous call before an asynchronous one
completes (in navigate()). If I sleep, then IE freezes also, so
I’m left with just retrying until I get lucky.


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

I don’t know if this is what you’re looking for, in my ClIEController[1]
lib, to wait until it’s really done loading the current page, you must

(1) wait for the busy property to be false
(2) wait for the ReadyState property to equal READYSTATE_COMPLETE

[1] http://clabs.org/ruby.htm

As far as the caching issues you talked about – the best I’ve done so far
with my acceptance testing is to manually set the browser options to load
the page fresh each time and delete everything in the Temporary Internet
Files during tear down.

The options to load fresh each time can be found here: Tools ->
Options… -> General tab -> Temporary Internet Files section -> Settings…

Technically, the Navigate method in the COM interface takes an argument
where you can specify it not load the document from the cache – but in
playing with this it doesn’t seem to work at all.

Chris

···

----- Original Message -----
From: “Eric Hodel” drbrain@segment7.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Monday, March 10, 2003 5:22 PM
Subject: Killing an WIN32OLE IE Object

To get to the point, how can I force a WIN32OLE object to wait until a
method completes properly? (specifically ie.quit)


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04

I don’t know if this is what you’re looking for, in my ClIEController[1]
lib, to wait until it’s really done loading the current page, you must

I’ve looked at it, but found it too big for the simple stuff I’m doing

(1) wait for the busy property to be false
(2) wait for the ReadyState property to equal READYSTATE_COMPLETE

or (3) use WIN32OLE_EVENT and wait for the correct Event to be fired (I
waited until the status text changed to “Intranet Zone”), but this
creates other problems, because IE blocks when you use WIN32OLE_EVENT
and sleep in ruby, it seems that even running the event handler’s loop
in another thread causes IE to block…

As far as the caching issues you talked about – the best I’ve done so far
with my acceptance testing is to manually set the browser options to load
the page fresh each time and delete everything in the Temporary Internet
Files during tear down.

Yep, do both of those.

Looks like I’ll have to busy-wait on #Busy or #ReadyState

···

Chris Morris (chrismo@clabs.org) wrote:


Eric Hodel - drbrain@segment7.net - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04