Forum Discussion

royd's avatar
royd
Regular Contributor
9 years ago
Solved

Problem with "FindAllChildren"

I am trying to find all menu items. I am getting error "Unable to find the object aspnetForm.", see the screcapture bellow. I am new to Jscript, Probably making a simple mistake, help is much appreciated.

 

Besides the issue I am having, I would also like to know is, once found how do I click on one of the menu, say "Admission Form". An exaple would be very helpful. Here is the code:

 

var page = Sys.Browser("*").Page("https://<testapplication>.com/MainMenu.aspx*");
var mainMenu = page.aspnetForm.panelMainMenu; //see the capture bellow
// Search for all menu links
var menuChild = mainMenu.FindAllChildren("contentText", 50, true).toArray();
menuChild = (new VBArray(menuChild)).toArray();

// Log the search results
if (menuChild.length > 0)
{
for (i = 0; i < menuChild.length; i++)
Log.Message(menuChild[i].contentText);
Log.Message("Total number of menu items found are: " + menuChild.length);
}
else
Log.Warning("No menu items found.");

 

 

 

 

 

Thanks in advance.