MichaelMcFarlan
14 years agoContributor
Website requires a inspection from the object browser before code works
I am trying to get the state out of this this webpage: http://www.paycheckcity.com/calculator/netpay/us/arizona/calculator.html.
You'll notice that if you change the state at that page, the entire website URL will change. I am using IE9. This is the code I have come up with (in javascript):
function getOpenState() {
lMatchStr = 'Page("http://www.paycheckcity.com/calculator/netpay/us/';
lMatchLen = lMatchStr.length;
lIE = Sys.Process("IEXPLORE", 2);
lCount = lIE.ChildCount;
for (var i = 0; i < lCount; i++) { // Look at all the children until we find the one that has the webpage we want
lName = lIE.Child(i).Name;
//Log.Message(lName);
if (lName.substr(0, lMatchLen) == lMatchStr) { // found the IE page
lRet = lName.substr(lMatchLen, lName.length - lMatchLen); // get everything past lMatchStr for further processing
return lRet.substr(0, lRet.indexOf("/", 0)); // return everything before the /
}
}
}
This works fine, but if you change the state this function is still getting the last state that the website was on. The only way I'm getting TestComplete to realize that the state has changed is if I use the object browser to inspect anything on the page.
Is there a better way to do this? Or this a bug in TestComplete? Or my code is incomplete somehow? I haven't done much web testing with TestComplete so any help would be appreciated. Also please let me know if my problem isn't clear.
You'll notice that if you change the state at that page, the entire website URL will change. I am using IE9. This is the code I have come up with (in javascript):
function getOpenState() {
lMatchStr = 'Page("http://www.paycheckcity.com/calculator/netpay/us/';
lMatchLen = lMatchStr.length;
lIE = Sys.Process("IEXPLORE", 2);
lCount = lIE.ChildCount;
for (var i = 0; i < lCount; i++) { // Look at all the children until we find the one that has the webpage we want
lName = lIE.Child(i).Name;
//Log.Message(lName);
if (lName.substr(0, lMatchLen) == lMatchStr) { // found the IE page
lRet = lName.substr(lMatchLen, lName.length - lMatchLen); // get everything past lMatchStr for further processing
return lRet.substr(0, lRet.indexOf("/", 0)); // return everything before the /
}
}
}
This works fine, but if you change the state this function is still getting the last state that the website was on. The only way I'm getting TestComplete to realize that the state has changed is if I use the object browser to inspect anything on the page.
Is there a better way to do this? Or this a bug in TestComplete? Or my code is incomplete somehow? I haven't done much web testing with TestComplete so any help would be appreciated. Also please let me know if my problem isn't clear.