Showing posts with label Ordinal Identifiers. Show all posts
Showing posts with label Ordinal Identifiers. Show all posts

Sunday, 1 June 2014

QTP - UFT - How to handle multiple objects with same properties - example


Solution - Use Ordinal Identifiers

we can use the following ordinal identifiers depending on the object
1) Creation Time ( only for browsers)
2) Index
3) Location

here is a scenario that describes it. I have created two buttons with same properties and when you spy using object spy on the buttons object spy displays same object properties.

Here is the above snapshot html code ( Copy the code in notepad and save with extension html)

<html>
<Head> <title> Object Identification </title> </head>
<body>
<Center>
<br>When you use object Spy on both the objects the properties will be same.
<br>
<br><Input type=Button name="s1" value="Button1"></Input>
<br>
<br>
<br><Input type=Button name="s1" value="Button1"></Input>
</Center>
</body>
</html>

When you use object Spy the following is displayed

Object Spy - Properties of first button"Class Name:=WebButton",
"abs_x:=649",
"abs_y:=118",
"class:=",
"disabled:=0",
"height:=23",
"html id:=",
"html tag:=INPUT",
"innerhtml:=",
"innertext:=",
"name:=Button1",
"outerhtml:=<input name=""s1"" type=""Button"" value=""Button1"">",
"outertext:=",
"title:=",
"type:=button",
"value:=Button1",
"visible:=True",
"width:=68",
"x:=649",
"y:=63"

Object Spy - Properties of second button
"Class Name:=WebButton",
"abs_x:=649",
"abs_y:=178",
"class:=",
"disabled:=0",
"height:=23",
"html id:=",
"html tag:=INPUT",
"innerhtml:=",
"innertext:=",
"name:=Button1",
"outerhtml:=<input name=""s1"" type=""Button"" value=""Button1"">",
"outertext:=",
"title:=",
"type:=button",
"value:=Button1",
"visible:=True",
"width:=68",
"x:=649",
"y:=123"

If you ignore the "y" and "abs_y" property, rest of the properties are unique.

If you add these properties to Object Repository, UFT/QTP adds the objects to OR with ordinal identifiers as Index.

 
 

'when recording
Browser("Object Identification").Page("Object Identification").WebButton("Button1").Click
Browser("Object Identification").Page("Object Identification").WebButton("Button1_2").Click

' when using descriptive programming
Browser("name:=Object Identification").page("title:=Object Identification").webbutton("name:=Button1","Index:=0").Click
Browser("name:=Object Identification").page("title:=Object Identification").webbutton("name:=Button1","Index:=1").Click

 

Saturday, 10 May 2014

QTP - UFT - Ordinal identifiers

what are ordinal identifiers in QTP / UFT
 
 
 
 
The following are called Ordinal Identifiers in QTP / UFT
 
  1. Index
  2. Creation time
  3. Location
 Note:- Creation Time will be displayed only when we are working with Internet Explorer Browser Object