Browser closing before the page is loaded completely

I need to get the performance results for various internal webpages from fast loading page to very slow loading pages. It works fine for the pages which load faster. But for the slow loading pages, the agent machine is closing the browser before the page is actually loaded and it shows the result for partially loaded page.

For example: one of my webpage I’m testing renders the outer page layout very fast and then it does some JavaScript processing. This JS processing sometimes takes more than 15 seconds (depending on the page) before everything in the page is rendered. In this case when the page is showing loading spinner, the agent just closes the browser and result page shows the result for partially loaded page. It could be due to the fact that there is no network activity when the JS is being processed and the agent thinks this page is fully loaded.

So my questions are:

  1. Why would the agent close the browser even before the page is completely loaded?
  2. Is there any settings I can change to prevent from this happening?

I have already tried increasing the “Time Limit” on wptdriver.ini to 1200 from 120 and “Timeout” in urlBlast.ini to “3000” from 300. But this didn’t help.

(I have attached the screenshot of the page with loading spinner.)

Thanks in advance.

WebPagetest is mostly driven by network activity (and the onload event). It doesn’t know anything about your javascript running.

There is a “setDomElement” script command that you can use to tell it to wait for a specific DOM element to show up (though not sure how well that works these days - been a while since I tested it).

You can also use the “Minimum Test Duration” (time) in the advanced settings to force it to wait for say 60 seconds to see if that gives you the data you need.

I am looking for creative ways to tell WPT that my page is done loading without a wholesale extension of the timeout value with setActivityTimeout.

First I tried using setDOMElement looking for a class, but the DOM has a list of classes and I only know of one for sure (tested it with the one I know about but it didn’t seem to work).

Next I was hoping to combine setDOMElement with exec like this (spaces and indention added for readability):

setDOMElement id=wptDoneLoading exec var wptInterval = setInterval(function () { console.log('setInterval'); var domElements = document.getElementsByClassName('x4-grid-tree-node-leaf'); console.log('domElements: '+domElements+ ', length: '+domElements.length); if (domElements && domElements.length > 0) { console.log('in the if'); var el = document.createElement("div"); el.id = 'wptDoneLoading'; document.body.appendChild(el); clearInterval(wptInterval); } }, 250);

That didn’t work, so I tried changing the ID of an existing DIV in the same manner but that also didnt work. My last attempt is only valid for IE (according to the docs) but it is also not working because window.webpagetest doesnt seem to exist:

waitForJSDone exec var wptInterval = setInterval(function () { console.log('setInterval'); var domElements = document.getElementsByClassName('x4-grid-tree-node-leaf'); console.log('domElements: '+domElements+ ', length: '+domElements.length); if (domElements && domElements.length > 0) { if( window.webpagetest ) { console.log('calling window.webpagetest.done'); window.webpagetest.done(); } else { console.log('no webpagetest object to call done on!'); } clearInterval(wptInterval); } }, 250);

I am using AMIs ami-04320e41 and ami-92320ed7. Any assistance would be appreciated, thanks!

Doc Reference:
https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting#TOC-setDOMElement
https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting#TOC-waitForJSDone
https://sites.google.com/a/webpagetest.org/docs/using-webpagetest/scripting#TOC-exec