mgreen
6 years agoContributor
FindAll returns blank in log - help!
Hi All -
Trying to get back some data when doing the "FindAll" method. "Find" seems to work fine and prints to the log fine. Whenever I run FindAll, it does not give me any error - but the log is literally empty. Can someone point out what I'm doing wrong here?
This works:
function Find() {
Results = NameMapping.Sys.browser.page.nav.Find("contentText", "administrative", 1, 1000);
Log.Message(Results.MappedName);
}
This does not work:
function Find() {
Results = NameMapping.Sys.browser.page.nav.FindAll("contentText", "*", 1, 1000);
Log.Message(Results.MappedName);
}
Any ideas? Many thanks
further to cunderw
You may need to explicitly convert the items that FindAll returns to an array
function Find() { Results = NameMapping.Sys.browser.page.nav.FindAll("contentText", "*", 1, 1000).toArray(); for(var i=0;i<Results.Length;i++){ Log.Message(Results[i].MappedName); //you could break early: if(Results[I].MappedName=='TableName') { break; } }
} //I tend to use for(var i=Results.length-1;i>=0;i--) because TC returns the find results from the leaf furthest down the hierarchy first and traverses up and in the majority of cases I want to look from the top level down - personal preference though