how to identify objects in qtp

QTP(Quick Test Professional) identified the Objects from the web application i.e Test Objects .

QTP has 4 types of Object Identifiers

1. Mandatory Properties
2. Assistive Properties
3. Ordinal Identifier
4. Smart Identification




QTP mainly identify the objects in Desktop,Web applications using mandatory objects Ex:name,Id.
Quick Test Professional uses identification properties to identify the Test Objects ,Run Time Objects in Web,Desktop application.

So in order to test a application may be it is Desktop or Web application you need to identify the Test Objects in Application ,in order to define the Framework for your application you need Test Objects to identify the application Elements.Today we are going to learn QTP object identification Types.


Mandatory Properties:


Mandatory properties are those properties where QTP identify the objects while recording the Test Script.

Ex:
Systemutil.Run "iexplore","http://qaqtptutorials.wordpress.com"
Browser("Software Testing Tutorials").page("Software Testing Tutorials").Sync
'To check the Text box
Browser("Software Testing Tutorials").page("Software Testing Tutorials").WebEdit("name:=Username").Sync

Here we used name as mandatory property for WebEdit Test Object Class.

Assistive Properties:


If QTP has not identifying the objects with Mandatory Properties then QTP will use additional property to identify the Test Objects in application.

If you are using descriptive programming  with out Object Repository then we can use more properties to identify the Test Objects in application like below

Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=Username").Set "xxxxxxxx"
Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("id:=password").Set "xxxxxxxx"

Ordinal Identifier:


We can use Ordinal Identifier to identify the Test Objects in Application ,in this we have Creation Time,Index,Location features to identify the Objects in application.

We can use this ordinal identifier if application having no of text boxes which is having some same properties at that time we can use.

First Name:Text Box 1
Last Name:Text Box 2
Middle Name:Test Box 3

Here for each text box we can identify as index:=0 ,Index:=1 , index:=2
Now we can write the test script as


Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=test","index:=0").Set "Rajesh f"
Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=test","index:=1").Set "rajesh s"
Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=test","index:=2").Set "Rajesh t"

Same Example for Location

Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=test","location:=0").Set "Rajesh f"
Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=test","location:=1").Set "rajesh s"
Browser("name:=Software Testing Tutorials").Page("title:=Software Testing Tutorials").WebEdit("name:=test","location:=2").Set "Rajesh t"

Same we can use it for Creation time also ,mostly we can use it for browsers close functionality.While opening the browser some creation time will create at that time we can use this technique.

Smart Identification

QTP is not able to find the test objects in application with above three properties at that time qtp automatically identify the test objects using Smart identification mechanism.

Navigation to Object Identification in QTP

Tools-->Object Identification.


No comments:

Post a Comment