waitForPageLoad not really waiting for the page to finish loading

I have a waitForPageLoad(20, STOP_ON_FAILURE) that is not really waiting for the page to load - the script continues and fails at a later check. Any suggestions on how I can really get it to halt at this step if the page hasn’t completed loading?

Annoying, right?

The question is, what does page load actually mean? In effect, it’s the resources identified by the HTML document (including the HTML itself, images, JavaScript and CSS). Problem then becomes, if the page sends requests to the server for more resources (ajax calls for example) the page isn’t actually “ready” even though it is technically “loaded.”

The cure:

Wait for a set of things unique to the page that should be present and visible. You could also add a fixed delay after that.

If you can nail that requirement for all your pages, you can say good bye to “is the page really ready” issues.

So, there is no one-shot command/API to solve this – the solution is in the (your) approach.

Hope that helps?


Probably the best answer to one of the most asked questions here.

1 Like

That makes a lot of sense - thanks Russ! I’ll change my approach a bit.

1 Like


I should have said…

There are other things, of course, like waiting for jQuery/Angular etc. But first see if the above gets you into a more rational state.

1 Like

@Morgan, Lastly…