Respected Contributor.
Respected Contributor.

Why aren't the document.XXXX / window.onload events firing in TruClient?

I'm trying to use the below JS code to trap 1) When the DOM content has loaded and 2) when the complete page has finished loading. I've added window.alert functions to trigger when these events fire (Side question: is there a way to output this to the TruClient Notifications section during the run???) but they never fire, so I'm suspecting something is interfering with the detection of these events, can anyone offer any hints as to what I might be doing wrong, or a different way to try what I am attempting?

LR.startTransaction ("PDP_DOM_Loaded");
LR.startTransaction ("PDP_Document_Complete");
//Generate URL and write selected URL to output log
var myURL = "http://qawcs.ballarddesigns.com/washed-percale-duvet/casa/florentina/spring/2012/235711"
//"http://" + LR.getParam("host") + LR.getParam("PDP_Link");
LR.outputMessage("Selected URL: " + myURL);

//Open desired URL

//document.ready = Doesn't work either!!!!
document.addEventListener("DOMContentLoaded",function(event) {
window.alert("DOM Content Loaded");

//wait until page has finished loading before checking final endpoint
window.onload = function () {
window.alert("Onload Event");
//Determine if a 404 page was returned by retrieving the value of the gwt_view_name object
var returnViewType = document.getElementById("gwt_view_name");
var returntext = returnViewType.getAttribute("value");

//Determine if the product is no longer available
var returnNoLongerAvailable = document.getElementsByClass("gwt-product-detail-widget-base-expired-label");

window.alert("returnText = " + returntext + " and returnNoLongerAvailable length is " + returnNoLongerAvailable.length);

if((returntext == "ProductDetailView") && (returnNoLongerAvailable.length == 0))
pageFound = "true";
} else {
pageFound = "false";

0 Replies
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.