Forum Discussion

royd's avatar
royd
Regular Contributor
8 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 appreci...
  • shankar_r's avatar
    8 years ago

    You dont't need to convert the below to array.

     

    mainMenu.FindAllChildren("ObjectType","link", 50, true);

    When you use FindAllChildren by default it will return as a Array.

     

    FYI.

    • FindAllChildren Method (Common for All Test Objects)
      Declaration

      TestObj.FindAllChildren(PropNamesPropValuesDepthRefresh)

      TestObjA variable, parameter or expression that specifies a reference to one of the objects listed in the Applies To section
      PropNames[in]   Required   Variant   
      PropValues[in]   Required   Variant   
      Depth[in]   Optional   IntegerDefault value: 1   
      Refresh[in]   Optional   BooleanDefault value: True   
      ResultAn array of the tested objects.

     

     

     

    Once you got the list of menus available from the Pane to menuChild object.

     

    You can script something like below.

     

    var menuChild = mainMenu.FindAllChildren("ObjectType","link", 50, true);
    
    // Log the search results
    if (menuChild.length > 0)
    {
    for (i = 0; i < menuChild.length; i++)
    //For clicking 
    menuChild[i].Click();

    //You can do your stuffs } else Log.Warning("No menu items found.");