Forum Discussion

alan-mullin's avatar
alan-mullin
Occasional Contributor
5 years ago

FindChild method finding one child object but not finding the rest of the child objects

My tested application uses a dynamically built menu. If 7 manuals are installed, it displays 7 items, if 6 are installed it shows 6, and so on. TestComplete is mapping the menu items the same way each time the application is run.

 

They all get mapped under an object called "SectionLibrary" in NameMapping.

Here is a trunctated inheiritance tree:

SectionLibrary

  • textnode
  • shadowroot
    • panel (Vehicle Type, this object FindChild locates perfectly)
    • textnode
      • shawdowroot
        • panel (Manual Type, this FindChild does not seem to locate)
        • textnode
          • shadowroot
            • Panel (Specific vehicle, have not gotten this far yet)

On screen, renderd as a nested menu, it shows as

Vehicle Type

  • Manual Type
    • Specific Vehicle

 

 

For Vehicle Type, it returns an object of Width X and Height Y, clicks on it fine, and this brings up the next level of the menu. The level in the menu chokes it.

 

propArray = new Array("contentText", "ObjectType");
valArray = new Array("Truck","Panel);

object = sectionLib.FindChild(propArray, valArray,7);
object.Click();
// This works perfectly.

valArray = new Array("23*", "Panel");
object = sectionLib.FindChild(propArray, valArray,10);
/*
This returns an object of dimensions 0x0, but does not appear to be the same object 
Object Spy returns from the screen. */
  • FindChild finds the FIRST object that matches the criteria, working from the bottom of the tree up.  So, it found exactly what you suggested... but not the one you were looking for.  You may need to expand your property array and value array to include additional criteria.  You might also want to consider starting further down the tree rather than from sectionLib.  

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    FindChild finds the FIRST object that matches the criteria, working from the bottom of the tree up.  So, it found exactly what you suggested... but not the one you were looking for.  You may need to expand your property array and value array to include additional criteria.  You might also want to consider starting further down the tree rather than from sectionLib.