5 Replies Latest reply on Mar 3, 2011 11:59 PM by Jimmytech

    Can I use objXfa.ChildObjects( ) to filter?


      I have a subform that typically contains N+1 child objects: typically 1 header element and N rows.  I want to get the number of children, without making assumptions on the number of non-Row children (ie. I don't want the script to break just because a footer element was added).  All of the rows have the RO property "name" set to "sfRow" (while the header's name is set to "sfHeader").  So following the lead of other QTP testing domains, I wrote:


          Function GetNumRows( testobjSubform )
              Dim oMatchingDesc
              Set oMatchingDesc = Description.Create()
              oMatchingDesc("name").value = "sfRow"
              GetNumRows = testobjSubform.ChildObjects( oMatchingDesc ).Count

          End Function


      This function consistently returns N+1, not the desired N, nor 0 (which would indicate my Description was filtering too much).


      So, I assume AcroQTP's implementation of object.ChildObjects( [x] ) is different from all other (example help-doc below) implementations of object.ChildObjects( [x] ).  Is this correct?






      Returns  the collection of child objects contained within the object.

      Important  Information

      The method  returns the child objects that fit the description specified (using the Properties object).


      object.ChildObjects ([Description])

      Syntax  Details

      objectAny Visual Basic test object.
      DescriptionOptional. An Object object. The Properties (collection)  object containing the description of the objects you want to find. 
      Tip: You can retrieve a  Properties collection using the GetTOProperties method or you can build a Properties collection object using the Description  object.  For more information on the Description object, refer to the  Utility section of the QuickTest Professional Object Model Reference.