How to identify dynamically changing objects in QTP ?

Consider an example where you are having a tree with nodes [can be folder or directory]. The tree as a whole is designed as a web table and sub-folders again as a sub-web table. It is easy to identify the index of the tree node while recording, but during playback when an additional folder or directory is added the index will be changed. In this kind of situation where the index of the objects changes dynamically, there are two actions to be performed.

  1. Identify the properties of the object
  2. Identify the index at run time

Identify the properties of the object

  • Use object spy
  • Add the object to OR

Identify the index at run time

We can use the following piece of code once the properties are identified

For i = 0 to 1000
set sObjTable = Browser(“Browser”).Page(“Page”).WebTable(“index:=”&i)
If Browser(“Browser”).Page(“Page”).WebTable(“index:=”&i). exist Then
If sObjTable.GetROProperty(“property name that is not changed”) = <Value that is expected> Then
Set sRootFolder = sObjTable

End if
Else
Exit for
End If

Next

In a similar manner, we can identify checkbox and radio button objects whose index changes at run time.

This worked for me, hope it will be useful for you too.

Have questions? Contact the software testing experts at InApp to learn more.