QTP - Ordinal Identifiers

Advertisements


What are Ordinal Identifiers ?

Sometimes there are series of objects with same class name and properties. Lets us say in a window there are series of checkboxes with the same set of properties. If we want to act on those objects we need to uniquely identify them so that QTP will be able to act on it.

An Ordinal Identifier assigns a numerical value to the test objects which indicates its location or order relative to its group. The Ordered value enables QTP to recognize it uniquely when the inbuilt properties are NOT sufficient to do so.

There are 3 Ordinal Identifiers in QTP that can be used in different context:

  • Index

  • Location

  • Creation Time

Index:

An object appearing first in the page/Window will have a smaller Index value when compared to another object that comes later in the same page/Window.

Understanding - Index

The Value of index for the group of text boxes will be as follows:

Object NameIndex Value
TextBox 10
TextBox 41
TextBox 22
TextBox 53
TextBox 34
TextBox 65

Location:

The Location property works vertically from top to bottom and from left to right. Hence for the same case, the value of location for the group of text boxes will be as follows:

Object NameIndex Value
TextBox 10
TextBox 21
TextBox 32
TextBox 43
TextBox 54
TextBox 65

Creation Time:

The Creation Time property holds good only for web based application. When we open 2 browser sessions of the same website, QTP will not be able to recognize the window as both the window will have the same set of properties. Hence we can use creation time with which QTP will be able to act on the window.

'Will have CreationTime value = 0
SystemUtil.Run "iexplore.exe", "http://www.google.com"     

'Will have CreationTime value = 1	
SystemUtil.Run "iexplore.exe", "http://www.yahoo.com"      

'Will have CreationTime value = 2   
SystemUtil.Run "iexplore.exe", "http://www.microsoft.com"  

'Will have CreationTime value = 3  
SystemUtil.Run "iexplore.exe", "http://www.facebook.com"   

Hence to work on a specific browser, we need to explicitly mention the Creation time in OR or we can use description of objects which we will see in detail in descriptive programming section.

'Sync's www.google.com
Browser("creationtime:=" ).Sync     	          

'Gets the RO text property of www.yahoo.com 
Browser("creationtime:=1").GetROProperty("text")  

'Highlights microsoft.com
Browser("creationtime:=2").Highlight              


Advertisements
Advertisements