Most useful function in Test Complete – FindAllChildren

1
262

Fn“Knowledge is Power” famously pronounced by Francis Bacon in 16th century. This is true even today and in Test Complete as well; as more knowledge you have, the better for you. I am going to start a series which would cover the most useful functions in Test Complete.

FindAllChildren is one of the important and useful functions provided by Test Complete developers. This function can help to collect object information that are related. This can also help to minimize lot of objects (Name Mapped items) to be created. I will show you with a scenario that this is a way to drill the development reusable.

Consider an application where the developer has played a lot with panels, customizing the same and using it over and over. Let us imagine that the application is of three vertical panes, one as input, other as output and the middle one being the unit passes through. This can be imagined as a mapping of these and drawing the relationships, however the idea is to stress on the set up and not on the functionality.

SampleApplication

Focusing on the set up, each pane has multiple panels that look similar with different names, actually objects with provision of other actions (let us consider item 1/unit 1 etc as name object). Also take into consideration that there is no limit to the items in each pane, it may grow or reduce or might be replaced ; it is not advisable to map these objects. Here the problem is to crack: How are you going to operate on each name object? The answer is FindAllChildren.

 

In the code above, a dictionary object is created. The container (input/unit/output) is passed through when the function is called. Based on that using FindAllChildren/FindChild the container object is obtained and stored (named objTray). Now applying the FindAllChildren in objTray object based on the criteria required, there would be a list of items as the name objects. FindAllChildren returns an array of objects, looping them and adding them to the collection will help to reuse, count etc. Thus the designed function GetNameObjects collects the name objects then the required items can be filtered to work on the desired.

Syntax

 TestObj is the object from where the child items are to be searched, the parameters  PropNames and PropValues are the array of property names and its value respectively based on which the search is to be performed. Depth is the level of hierarchy until where the search needs to be performed. Shorter the depth faster the response of the search. Refresh by default is true which refreshes the cached objects. For more information on the function details, refer to Smart Bear online help; while in this article I focus where and how useful this function can help in test automation.

Therefore the FindAllChildren function is handy when it is non realistic to build mapped objects at dynamic times and obviously this proves to be better off in those times. The use of this function can be compared to be the descriptive mode with respect to QTP style of handling the similar situation. For more information on the Test Complete descriptive way read further to object-identification-in-testcomplete-descriptive-way

Happy Coding!!

1 COMMENT

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.