Vous êtes sur la page 1sur 6

gcreddy@gcreddy.

com

Test Object Model


a) Object:

Object is something, which has structure and properties.

b) Software objects:

We call windows, WebPages, buttons, edit boxes, check boxes etc. as software
objects.

c) Types of Object in QTP:

There are four types of object available in QTP.

i) Run time objects


ii) Test objects
iii) Utility objects
iv) Automation objects/User defined objects.

i) Run time objects: The objects present in the AUT. Ex: Buttons, links, etc…

ii) Test Objects: References of Run time objects. Ex: WinEdit, WinButton,
WebButton, Link, etc…

Note:
Test objects names vary from one environment to another.
Ex:
Run time objects Test objects in Test objects in VB Test objects in
windows Environment web Environment
Environment
buttons WinButton VBButton WebButton
Edit box WinEdit VBEdit WebEdit
Check box Wincheckbox Vbcheckbox Webcheckbox

iii) Utility objects

They are QTP reserved objects used for testing and result reporting.
Ex:
1. SystemUtil for launching/closing the application.
2. Reporter for defining results.
3. Services for inserting transaction points
4. Environment for using environment variables

iv) Automation objects/User defined objects


User can create objects; those can be used for performing specific operations. Ex:
Creating objects in file system object class, adodb.connection class, dictionary object
class, excel. Application class etc.

QTP Training 1
gcreddy@gcreddy.com

d) Types of Statements in QTP Test / Test Script


i) Declarations (Variables and constants)
Dim x, y, z
Const City, Price
ii) Object calls
Ex1: Dialog("Login").WinEdit("Agent Name:").Set "gcreddy"
Ex2: Browser("Google").Page("Google").Link("Gmail").Click

iii) Comments
iv) Flow Control Statements (Conditional & Loop)
Ex:) If Total=Tickets*Price Then
Msgbox "Test Passed"
Else
Msgbox "Test Failed"
End If

v) Function / Action calls


Ex: Call Login("gcreddy","mercury")
vi) Utility Statements
Ex1: SystemUtil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe"
**It launche the Application
Ex2:
SystemUtil.Run "C:\Program Files\Internet
Explorer\IEXPLORE.EXE","http://www.icicibank.com/"
vii) VB script other statements
Examples:
Option Explicit
Wait (14)

QTP Training 2
gcreddy@gcreddy.com

Object Repository
Object Repository:

It is a storage place of QTP where we can store the objects information and it also
acts as interface between the test script and the AUT in order to identify the
objects during execution.

Local Repository:

QTP creates a Local Repository for every action automatically during Recording.
That cannot be shared among tests.

User can add some more objects to Local repository

User can perform rename, delete operations in local repository. As it is QTP


internal file user no need to save modifications.

Navigation: Resource menu>object repository (Short cut key Ctrl+R)

QTP- Local Repository

QTP Training 3
gcreddy@gcreddy.com

Shared Repository:

User (Test Engineer) creates shared repository by adding objects. That can be
shared among number of tests.
Using this method user can perform modifications on objects easily.

Operations on Object Repository

Adding objects

a. Local Repository:

Navigation: open local repository (resource menu>object repository)


>objects>Add objects to Local>show the object>click ok
(No need to save separately, it saves automatically)

B. Shared Repository:

Navigation: Resource menu>object repository manager>object>Add


objects>show the window/object>click ok

o Selected object only


o Default object types
o All objects types
o Selected object types

(If we select first option it stores Selected objects only, if we select second option it
stores all default objects, if we select third option it stores All objects including static
objects, if we select fourth option, we have to select object classes then it stores
that class objects, we can select more than one class also.)

Renaming objects

a. Local Repository:

Resources > object repository >select object and right click >choose rename option
>modify the name>release the mouse.>close repository

b. Shared Repository:

Resources >object repository manager>file>open>browse path of the repository file


>file>enable editing>select object &Right click>choose rename option>modify the
name > release mouse>save the file & close repository manager.

Deleting objects

a. Local Repository:

Resources > object repository >select object and right click >choose delete option
>confirm deletion>. >close repository

QTP Training 4
gcreddy@gcreddy.com

b. Shared Repository:

Resources >object repository manager>file>open>browse path of the repository file


>file>enable editing>select object &Right click>choose delete option>confirm the
deletion >save the file & close repository manager.

Associating objects repositories to an action

Resources>Associate repositories>click add icon (+)>browse path of the


repository>Associate with an action>click ok

Merging Repositories

Resources > object repository manager>tools>object repository merge tool >browse


path of the first repository> browse path of the second repository>click ok>click
close>save the merged repository>close the repository manager.

Note: After merging also, source repository files will be available, if we do not want
source files we can delete.

Defining new test objects

Navigation: Object>Define new test object >Select Environment>Select Class of the


object>Enter name of the object>Click Add>click close>Select object >select
property name>enter value (like this select one by one properties and enter
values)>save

Note: This feature can be used for preparing tests before the AUT is ready.

Spying objects

For getting objects information, (Test objects names, property & Values) QTP is
providing a feature called Object Spy, using this we can get objects information.

Navigation>Tools>object spy>take hand icon & Show the object>get information


(Object Spy shows the specific objects all available properties with their values)

Note: As Object spy is an important feature, it can be available in 3 Areas.(1. In


tools Menu 2. In local repository 3. In Repository manager)

View Options

Locate in Repository

This feature can be used for identifying objects from application to repository.
Navigation: View>Locate in repository >show the object>click Ok>it locates
specified object in the repository.

Highlight in Application

This feature can be used for identifying objects from repository to application.

QTP Training 5
gcreddy@gcreddy.com

Navigation: Select object in the repository >view>highlight in application>it


highlights specified objects in the application.

Exporting Repository to an XML file

We can export our repository file to an xml file.

Navigation: File >export Test objects to XML Enter the file name and Save with xml
extension.

Importing Repository from XML file

We can import XML file to our repository.

Navigation: File>import from XML >browse path of the XML file >it loads objects.

Note: The purpose of this feature is Editing objects information outside of the QTP

Dynamic handling of object Repositories

Loading repositories during running, finding path of the repositories and removing
repositories is called Dynamic Handling of Object Repositories.

Using this feature we can increase QTP performance. To do this, QTP has provided an
utility object called “RepositoriesCollection”.

Syntax for Loading a Repository:


RepositoriesCollection.Add “Path of the Repository File”

Syntax for finding Position of the Repository:


Variable=RepositoriesCollection.Find(“Path of the Repository”)

Syntax for Removing the Repository:


RepositoriesCollection.Remove(position)

Syntax for Removing All Repositories:


RepositoriesCollection.RemoveAll

Example:
RepPath="C:\Documents and Settings\Administrator\My Documents\Login.tsr"
RepositoriesCollection.Add (RepPath)
systemutil.Run "C:\Program Files\HP\QuickTest
Professional\samples\flight\app\flight4a.exe"
Dialog("Login").Activate
Dialog("Login").WinEdit("Agent Name:").Set "sudhakar"
Dialog("Login").WinEdit("Password:").Set "mercury"
Dialog("Login").WinButton("OK").Click
pos=RepositoriesCollection.Find(RepPath)
RepositoriesCollection.Remove(pos)
RepositoriesCollection.RemoveAll

QTP Training 6

Vous aimerez peut-être aussi