cancel
Showing results for 
Search instead for 
Did you mean: 

contentDocument.readyState always "complete" in Chrome?

Highlighted
Community Hero

contentDocument.readyState always "complete" in Chrome?

Hi



I think this has come up before, but I didn't find any workarounds that I liked the look of?



I have a global function I use to wait for pages to load. As you might guess by the thread title, it does this by waiting for the readyState of the page to go to "complete".



It works perfectly with IE, but Chrome (v35) always returns "complete" while it's still loading.



From what I gather, this is a Chrome issue?



Does anyone have any other suggestions to work round this? The two browsers I have to test the site with are Chrome and IE so I'm trying, where possible, to use solutions that will work with both.



The page that's causing me real problems is a search page with a table on it. You do a search, the table contains the results. Problem being, none of the page elements change or are removed while the search happens. So I can't wait until an object appears or vanishes as they are all present, all the time, and only change when it re-renders the page on completion of the search. The browser does indicate that it's loading though and the readyState property of the page updates correctly for IE. But not for Chrome. So searches in Chrome are just a mess as it all gets way too far ahead of itself.



Grrrrrr. I hate Chrome.



(TestComplete v10.20 and I'm using VBScript)
7 REPLIES 7
Highlighted
Community Hero

RE: contentDocument.readyState always "complete" in Chrome?

Any idea if it's possible to monitor the loading spinner that shows in the tab at the page top while it's busy?



That would do. But I can't see anything relating to it when I look at the tab in the object browser ....
Highlighted
Community Hero

RE: contentDocument.readyState always "complete" in Chrome?

I believe I have a solution.



The "reload" button in the Chrome toolbar can be used.



While the page is busy, it changes the description text on the button to "Stop loading this page". Once complete, this changes to "Reload this page". Net effect is the same as checking the readyState in IE.



The project is already cross browser so has the browser in use stored in a global variable. So the wait for page load routine will use this to determine whether to use readyState (IE) or the reload button (Chrome).



Main thing to be careful of is if you are using multiple browser during the test as you need the BrowserWindow(<num>) object to get to the reload button. But you can either track this yourself or backtrace it using the content of the Address/Search bar to find the parent BrowserWindow you want.



Either way, it works and I can use it throughout the test(s).



Happy days. 🙂
Highlighted
Community Hero

RE: contentDocument.readyState always "complete" in Chrome?

Have implemented my solution now and it works great.



So Chrome uses the "reload" button and IE uses the readyState value.



It handles if it's the current page refreshing or going from one page to a new one.



It also handles it if there are multiple browsers open no problem. Whether it's several instances of the same browser or a mixture.



So far, it seems to work perfectly.



Of course, it would have been far easier if the readyState property in Chrome worked properly in the first place, but what can you do!
Highlighted
Community Manager

RE: contentDocument.readyState always "complete" in Chrome?

Hi Colin,

 


That's an interesting approach 🙂 Thanks for sharing it!


 


It's worth saying that TestComplete will recognize Chrome's toolbar buttons only after adding the Chrome_WidgetWin_1 class name to the Open Applications | MSAA project settings.

---------
Tanya Gorbunova
SmartBear Community Manager

Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
Highlighted
Frequent Contributor

RE: contentDocument.readyState always "complete" in Chrome?

Thanks for posting this, Colin.  I've been dealing with browser page load timing issues for months and trying to do things like waiting for page objects, adding delays, etc.  Very time consuming.



It bears mentioning that I really wish TestComplete would build this functionality into the Page.Wait() method.  That method is basically useless in Chrome at the moment.
Highlighted
Community Hero

RE: contentDocument.readyState always "complete" in Chrome?

Happy to help.



I suspect the Page.Wait() method falls foul of Chrome always reporting it's state as "complete". It's an annoying bug in the browser. That one little bug makes a simple task like waiting for a page to load very awkward.



Mind you, with all the sub-page level stuff going on in sites these days, which are detached from the page load status, it's hardly surprising.



I also do performance testing and we now have an in-house solution for timing sub-page stuff like Ajax events.



As browsers and sites get more complex, I guess it gets harder and harder for automated solutions to keep up ....
Highlighted
Frequent Contributor

RE: contentDocument.readyState always "complete" in Chrome?

Yes, for our pages with AJAX, I have to pair the page load monitoring method with another method that tracks our progress spinner... 🙂



Tracking the "Reload" button in Chrome seems to be working great based upon yesterday's tests.  I had to work through a few issues with finding the right BrowserWindow object (also wish TestComplete would nest Pages under BrowserWindows...), but I finally got that working as well.
New Here?
Join us and watch the welcome video:
Announcements
Script Wanted
Let's start July with new challenges!

Create a script to pass custom command-line arguments as a test parameter for the TechCorner tag!

Will you dare to take the challenge?


Top Kudoed Authors