Forum Discussion

komalak11's avatar
komalak11
Contributor
9 years ago

Can anyone please give me a sample code of using pointers in Test complete using C++/C#?

Hi,

 

I am trying to traverse through a list in my application. I want to use the concept of pointers for this. Can anyone please share me a sample piece of code for doing this, how to go about the pointers concept in Test complete?

3 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    Code languages in TestComplete are all script versions of the languages.  So, while C# and C++ syntax are used, they are not full code languages.  In fact, C# and C++ script are just a syntaxed version of JScript so I don't believe pointers are supported.

     

    However, if it is a list of items, depending upon how TestComplete recognizes the list, there are ways of traversing the list.  If you can give us information about the list you're working with, we might be able to help out.

    • komalak11's avatar
      komalak11
      Contributor

      tristaanogre, Thank you for the information.

       

      It's a simple traverse through a list, but they are not of the same datatypes and the relation between parent and child is not through any unique property. 

       

      I am using a property of TestComplete "Find Child" but I require a method to verify if the Child is the item of the parent. Without pointers how to traverse through any list?

      • tristaanogre's avatar
        tristaanogre
        Esteemed Contributor

        FindChild is a method, not a property.  You call it from the parent object like so:

        parentObject.FindChild(['className','Caption'],['newGrid','My Table'], 2)

        The above command will look for any child objects of parentObject that have a className of newGrid and a caption of 'My Table'.  It will look down to three levels... the immediate child, the grandchildren, and the great-grandchildren of parentObject.  It will find the first match and return it.  If it does not find a match, it returns an object with only the Exists property set to False.  If you want it to search only immediate children, set the third parameter to a zero.  That should give you exactly the child object of parentObject.  So... no need to traverse any list.

         

        However, if you want to bring back a list of all matching objects to search for a particular one, change the code to

         

        parentObject.FindAllChildren(['className','Caption'],['newGrid','My Table'], 1)

        This will return a safe array of all matching children.  To traverse that array, call the "toArray" method of the object and then use standard array traversing using a for loop from 0 to the length of the array.

         

        So.... no pointers necessary.