QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values

In this example, I created three of the same exact Links below. When you have multiple objects with the same exact property values, QTP/UFT will be confused when trying to select one of these objects. We can simply fix this issue by adding an Index during the identification process. The index is a great way of identifying the object in the order they are displayed on the page. The index always starts with 0.

Example:

Test Test Test

If you try identifying one of the Link objects above with their name or any other property, QTP/UFT will throw you an  error. By adding an index to the identification properties, we can easily select any of these three Links. See code below:

 

Code to identify Link 1:

Browser("name:=QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values \|").Page("title:=QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values \|").Link("name:=Test", "Index:=0").click

Code to identify Link 2:

Browser("name:=QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values \|").Page("title:=QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values \|").Link("name:=Test", "Index:=1").click

Code to identify Link 3:

Browser("name:=QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values \|").Page("title:=QTP/UFT beginner tutorial- Using Index to differentiate objects with the same property values \|").Link("name:=Test", "Index:=2").click

There you have it! You are a QTP/UFT champion. Identifying objects has never been this easy. Stay tuned for more amazing QTP/UFT tutorials.

Pin It on Pinterest

Clef two-factor authentication