WebDocument State is "complete" in Firefox while page load

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
michael23
Posts: 9
Joined: Mon Jun 23, 2014 3:36 pm

WebDocument State is "complete" in Firefox while page load

Post by michael23 » Fri Dec 05, 2014 10:39 am

In my testscript I must waiting until document loading is finished. For these I use the method WaitForDocumentLoaded. But in firefox this will takes no effect - the method won't be wait for loading the document. In IE and Chrome it works fine and ranorex will waiting until the document is fully loaded and complete. For debugging I logged the state of the document (see the code below).

Code: Select all

Ranorex.Report.Info("wait0"+repository.Matrix.Self.State);

if (!repository.Matrix.AccessManagementPanel.Lists.ReaderEventListPanel.SelfInfo.Exists())
	repository.Matrix.AccessManagementPanel.Lists.SideMenuPanel.ReaderEventList.Click();
	
Ranorex.Report.Info("wait1"+repository.Matrix.Self.State);
repository.Matrix.Self.WaitForDocumentLoaded();
Ranorex.Report.Info("wait2"+repository.Matrix.Self.State);
Result in firefox:
00:06.837 Info User wait0complete
00:07.153 Info User wait1complete
00:07.171 Info User wait2complete

Result in ie or chrome:
00:07.415 Info User wait0complete
00:08.061 Info User wait1loading
00:08.146 Info User wait2complete

Why the state in firefox is always complete and why the method waitfordocumentloaded doesn't work?

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

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

Post by Support Team » Tue Dec 09, 2014 11:16 am

Hello michael23,

Unfortunately, we are not able to reproduce this issue.

May I ask you to answer following questions?
  • • Which version of Ranorex do you currently use?
    • Which version of Firefox do you use?
    • Is the issue reproducible on a different website as well?
Thanks,
Robert
.
Image

michael23
Posts: 9
Joined: Mon Jun 23, 2014 3:36 pm

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

Post by michael23 » Wed Dec 10, 2014 8:49 am

I use Ranorex version 5.2.1. I've tested the issue with Firefox version 24.6.0 ESR, 31.3.0 ESR and also 34. The result was always the same. My website is an internal tool, therefor I can't share a link or the like. The issue can be reproducing by testing an website with long response time (e.g. slow lan connection or so on).

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Wed Dec 10, 2014 2:44 pm

The only time I've seen something like this is when the web page has late-loading scripts. That isn't a Ranorex issue. You would need to put more wait time in, either by adding delays, or by using WaitFor.Exists() with an XPath that contains "@state='complete'".

Code: Select all

// in the repo:
MyDom ==> /dom[@domain='www.mydom.com' and @state='complete']

// in the action table:
Delay -> 1s
WaitFor -> Exists -> 2m -> MyDom
Delay -> 500ms
WaitFor -> Exists -> 2m -> MyDom
Delay -> 500ms
WaitFor -> Exists -> 2m -> MyDom
Validate -> Exists -> MyDom
This will allow the system to wait for the page to actually complete, if it is late-loading some scripts.
Shortcuts usually aren't...

michael23
Posts: 9
Joined: Mon Jun 23, 2014 3:36 pm

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

Post by michael23 » Wed Dec 10, 2014 5:42 pm

Waiting for /dom[@domain='www.mydom.com' and @state='complete'] isn't very helpful, because the dom is always available and the readystate of the webdocument in firefox is complete at this moment. I think there is a problem between an js-script and the firefox. So the js-script will set the complete-state to early/fast.

krstcs
Ranorex Guru
Posts: 2683
Joined: Tue Feb 07, 2012 4:14 pm
Location: Austin, Texas, USA

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

Post by krstcs » Wed Dec 10, 2014 7:25 pm

If you aren't navigating, then sure it will always be complete, once it gets completed, no matter which browser you are using. But, if you aren't navigating, then there is nothing to wait for.

And, the dom is most definitely not "always available" if you are actually navigating. This is how I've been doing it for a few years and it works perfectly for every site I've tested, with Chrome, IE 8/9/10/11 and Firefox. The state will change to something other than complete while the browser is loading the html and parsing any script elements. Sometimes it will incorrectly flip to complete and then load a script, which is what my example was catching. But this is an issue with the site, not Ranorex.


You could also try adding Validate.Exists() on an element that loads late and let Ranorex attempt to find it for the timeout specified. Just put this at the spot that you are having the problems and see if it helps.
Shortcuts usually aren't...