WebDocument State is "complete" in Firefox while page loads

Class library usage, coding and language questions.
lyn5000
Posts: 50
Joined: Mon Feb 13, 2012 5:52 pm

WebDocument State is "complete" in Firefox while page loads

Post by lyn5000 » Wed Feb 15, 2012 7:24 pm

After navigating to a web page in Firefox9.0.1, the WebDocument State is "complete" immediately before the page has finished loading (see code below; the while loop is never entered because .State is "complete" immediately yet I can still see the page loading).

I've also tried "Firefox.Instance.DOM.WebPage.WaitForDocumentLoaded();" but it doesn't wait.

However, it works in IE9 (see code below) as does WaitForDocumentLoaded(). The while loop is entered and you see "loading", "interactive" etc.

Is this an issue with Firefox or Ranorex? What is the workaround?

Windows 7 Pro SP1.
Ranorex 3.2.1.15734

FIREFOX:
Host.Local.OpenBrowser("", "FIREFOX", "", true, true);
string myURL = "http://www.microsoft.com{ENTER}";
Firefox.Instance.Form.NavigateEditBox.PressKeys(myURL);
while (Firefox.Instance.DOM.WebPage.State!="complete")
{
    Console.WriteLine(Firefox.Instance.DOM.WebPage.State);
}
Firefox repository:
Item:"Form"
(Absolute Base Path "/form[@class='MozillaWindowClass']")

Item:"NavigateEditBox"
("/form[@class='MozillaWindowClass']/container[@accessiblerole='PropertyPage']/toolbar[@accessiblename='Navigation Toolbar']/combobox[@accessiblename='Go to a Website']/text[@accessiblename='Go to a Website']")

Item:"DOM"
Path:"Base: /dom" (Absolute Base Path "/dom")

Item:"WebPage"
Path:"(same as base)" (Absolute Path "/dom")

IE:
Host.Local.OpenBrowser("", "IE", "", true, true);
string myURL = "http://www.microsoft.com{ENTER}";
IE.Instance.Form.NavigateEditBox.PressKeys(myURL);
while (IE.Instance.DOM.WebPage.State!="complete")
{
   Console.WriteLine(IE.Instance.DOM.WebPage.State);
}
IE Repository:
Form
"/form[@class='IEFrame']"

NavigateEditBox "/form[@class='IEFrame']/element[@class='WorkerW']/container/element[@controlid='41477']/text[@class='Edit']"

Item:"DOM"
Path:"Base: /dom" (Absolute Base Path "/dom")

Item:"WebPage"
Path:"(same as base)" (Absolute Path "/dom")

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: WebDocument State is "complete" in Firefox while page loads

Post by Support Team » Thu Feb 16, 2012 1:06 pm

Hi,
lyn5000 wrote:After navigating to a web page in Firefox9.0.1, the WebDocument State is "complete" immediately before the page has finished loading (see code below; the while loop is never entered because .State is "complete" immediately yet I can still see the page loading).
lyn5000 wrote:Is this an issue with Firefox or Ranorex? What is the workaround?
I tried it with Firefox 10.0 and it works as expected. But why do you use the complete state of the webpage? The recommended way is to validate if an element exists on the page. Then you can be sure that the webpage is ready for your needs. Sometimes it could be possible that you get the complete state of your webpage, but the site doesn't finish rendering, therefore we recommend to use the validate step.

Regards,
Peter
Ranorex Team

lyn5000
Posts: 50
Joined: Mon Feb 13, 2012 5:52 pm

Re: WebDocument State is "complete" in Firefox while page loads

Post by lyn5000 » Thu Feb 16, 2012 5:55 pm

I can't use Firefox 10 (10.0.1) since after installing the Ranorex Add-On (Ranorex Automation 3.2.1.15734) it says it is incompatible with Firefox 10.0.1.

I used the complete state to validate that the page has finished loading to simulate the user waiting for the page to load so they can read it before clicking anything as well as checking our page actually reaches the complete state in case there is some issue with it. I will try by checking for an element existing as a signal that the page has finished loading then and see if that meets our needs. I imagine there are situations where an element exists on the page but the page is still loading though so I'd rather wait for the complete state AND the element to exist.

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: WebDocument State is "complete" in Firefox while page loads

Post by Support Team » Fri Feb 17, 2012 10:21 am

Hi!

Ranorex Version 3.2.1 doesn't support Firefox 10 - Peter made a typing error, he didn't do it with Firefox 10 but with Firefox 9.
Firefox 10 will be supported with next Ranorex release, which will be available in the next week or the week after the next week.

Meanwhile, please install Firefox 9 again, it will work with Firefox 9.

On your other issue, as Peter said before, the recommended way would be to validate on an element on the webpage if the element exists.
Of course, you can also combine and check for the complete state and the element exists.

Regards,
Martin
Ranorex Support Team