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 sub web table. It is easy to identify the index of the tree node while recording, but during playback when and additional folder or directory is added the index will be changed. In these kind of situations where the index of the objects changes dynamically there are two actions to be performed.

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

Identify the properties of object

  • Use object spy
  • Add object to OR

Identify the index at run time

We can use 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 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.



Author: InApp
We are a custom software development company offering Testing Services, Application Development, Mobility Solutions & more. Customers: Startups - Fortune 500

1 Comment

  • Pooja

    Great post! I found this article a very informative. The information given in this article about QTP is very useful. Thanks for all the information you provide through this site. Keep sharing nice article like this!

Leave a Reply

20 − five =