Page 1 of 1

WebDocument State is "complete" in Firefox while page load

Posted: Fri Dec 05, 2014 10:39 am
by michael23
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?

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

Posted: Tue Dec 09, 2014 11:16 am
by Support Team
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

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

Posted: Wed Dec 10, 2014 8:49 am
by michael23
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).

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

Posted: Wed Dec 10, 2014 2:44 pm
by krstcs
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.

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

Posted: Wed Dec 10, 2014 5:42 pm
by michael23
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.

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

Posted: Wed Dec 10, 2014 7:25 pm
by krstcs
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.