WebPagetest Forums
Problem with JS-function (onload) and execAndWait - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: WebPagetest (/forumdisplay.php?fid=7)
+--- Forum: Bugs/Issues (/forumdisplay.php?fid=10)
+--- Thread: Problem with JS-function (onload) and execAndWait (/showthread.php?tid=12009)



Problem with JS-function (onload) and execAndWait - KaiBra - 01-28-2013 09:25 PM

Hi,

I recently read in the forum, that it is not recommended to use execAndWait with JavaScript involved, unless you really want to measure the method your are calling.

The following problem only occurs on a Server with long responsetimes:
I've got a problem with a page (b) inbetween two pages (A and C), which automatically forwards to page C, when a click on page A is executed (A->b->C).

Measuring A->b->C works fine with IE using execAndWait ...click();.
But when I try the same script using Firefox, measurement stops after loading page b (A->b).


The original script (execAndWait ...click()) works fine measuring the same site on a faster server (FF and IE) and measuring the same site on the server with long responsetimes using IE.

So the problem only occurs with FF and a server with long responsetimes.
See pictures fastservers.bmp and slowserver.bmp.
Page b looks like this:
Code:
...
function goon() {
location.replace("Page C");
}
...
<body onload="goon()">
...
The script look like this:
Code:
logData    0
setCookie    ...
navigate    url
logData    1
execAndWait    document.getElementById('id').click();
Usually it takes about 0.8 secondes to load site b, and everything works fine.
On a different environment though, it takes longer and the measurement stops after page b has been loaded.
It looks like the combination of browser and long responsetimes are responsible for the sudden "measurement-stop" of execAndWait.

Does anyone have an idea for a workaround?
I tried to call goon() after executing the click on A (execAndWait), but this gave me waterfalls with incorrect measurement-times.
I also had a look at the method "setDOMElement", but I couldn't figure out how exactly it works (http://www.webpagetest.org/forums/showthread.php?tid=12004).

Thanks in advance,

Kai

(INFO 28/01/2013: Moved thread from "Discuss Test Results" to "WPT - Bugs/Issues")


RE: Problem with JS-function (onload) and execAndWait - pmeenan - 01-29-2013 02:02 AM

I don't think it's a problem with the execAndWait specifically, it's probably a result of the activity timers triggering an end condition. The best solution would be either setDomElement or setDomRequest but the first isn't working for you and setDomRequest hasn't been implemented for Firefox or Chrome yet (though it shouldn't be too hard so I can see about doing it in the next couple of weeks).


RE: Problem with JS-function (onload) and execAndWait - KaiBra - 01-29-2013 02:55 AM

Thanks a lot for your answer!
This would be great, we are looking forward to it.

Regards,

Kai