Re: ReadyState property



"Matt Adamson" <Adamson_matthew@xxxxxxxxxxx> wrote in message
news:%23wzRraWNHHA.780@xxxxxxxxxxxxxxxxxxxx
I'm writing an IE wrapper object to use in NUnit tests to test our web
application. I've created methods such as WaitForReadyStateToComplete
which take a HTMLDocument object or a InternetExplorer object.

1) I'd like to know the difference between the two ready state
properties

In the presence of frames, there may be multiple documents loading at
once within a browser. Each document would have readyState property
reflecting its own state. The browser's ReadyState property reflects the
overall state of the frameset.

2) I also noticed a lot of other IE objects such as
HTMLTable and HTMLTableRow have readyState as a property too.

This is only used for data-bound elements. See datasrc attribute.

while(htmlDocument.readyState != "complete")
{
Trace.WriteLine("Ready state = " +
htmlDocument.readyState.ToString()); Thread.Sleep(10);
}

That's not going to work. MSHTML is a single-threaded component. It
cannot make any progress while its thread is suspended. You need to run
a message pump for the document to ever become complete. At the very
least, call Application.DoEvents instead of Sleep (but beware
reentrancy). Better yet, turn your program into a state machine from a
linear set of instructions: sink events from the document, start the
next piece of work in response to onreadystatechange event (or
DocumentComplete event, in case of WebBrowser object).
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.


Loading