Tuesday, April 14, 2015

Object Repository

From webex training videos:


-          Sections in Object Repository:

1.       Description Properties --- always use this. This properties are unique to the object.

2.       Visual Relation Identifier --

3.       Ordinal Idenfier   -- identifying object which are similar. Like index thing is there here.

4.      Additional Details( Smart Identification – QTP has inbuilt algorithm to identify object. Set always Smart identification to false, for safe side, because QTP uses its own technique if enabled.)

-          Object repository has a icon in menu bar –Highlight Application, that will highlight the objects in a application based on the selection you make in Object Repository


 - The benefit if the objects are there in Object Repository is we can drag and drop them from OR to Expert View section, that generates line of code on its own.

- Share Object Repository:
Share Object Repository: To share the object Repository across multiple scripts without really creating them again.

1. Go to Resources-> Object Repository Manager

Once you are in there, select add objects icon in the menu bar, that will help you add objects to the Shared Object Repository.

 And then save it. It will have automatically added extension .tsr.

Looks like Object Repository Manager is used to create new Object Repository(shared) and these OR's will be used for future reference(Object Repository created using OR Manager is always a Shared OR).


In order to add another object repository to the script:

Go to Resources -> Associate Repository ->  Add corresponding object repository that you wanted to Add (by clicking + symbol) -> Select Action that you want to associate with.

Note: When you click Add, it will open a window that will help us to access Object Repositories(Shared Repository) file saved in the system, and associate it with the current test/action.

Always try to use Shared Repository( the above two things will help you to create and associate), because if you are trying to use existing objects for another script you need not make duplicate repository, can make use of existing one. That is possible only if you have created one as shared repository. 

Note: Looks like Non Shared Object Repository does not exist. Either Local Repository or Shared Repository exist. Local Object Repository when saved(Export object Repository option) will be changed to Shared Object Repository. Below points explains the same.

2. Other way of sharing object repository:

Go to Object Repository, save it to the folder where Shared object Repositories are stored, for sue the file will be saved as .tsr.

Later you could pull that OR by going to Resource->Associate Repository -------


Note: The scenario of Shared object Repository is:

1. Take the flight login page, record the login actions(so that local login object repository gets created). Lets suppose this one is in Action 1
2. Then Record the logout, local object repository gets created for logout. This code is in Action 2
3. Now save the each Login and Logout local repositories(by clicking save in the Object respository section). Bot the object repositories will be saved as Shared object repository(.tsr).
4. Merging both Flightlogin.tsr and FlightLogout.tsr into one shared object repository "FlightLoginLogout.tsr"

Then Go to Object Repository Manager->Tools->Object Repository Merge Tool (this is in QTP 5) Once merged Shared Repository is created(make sure it is associated into both actions), using Resource -> Associate Repository.  (as shown below, drag the actions to the right window)








Note: The Repositories associated with that actions are viewed top right corner of the object Repository window of that action.


RepositoriesCollection Object


A collection object that enables you to programmatically manage the run-time collection of shared object repository files associated with the current action.

Adds an object repository file to the specified index position in the run-time collection of shared object repository files associated with the current action.

Syntax

RepositoriesCollection.AddRepositoryPath, [Position] 

Note: Repository collection is used to while adding shared object repository using the code.

- Source : https://diptichaudhary.wordpress.com/2014/04/25/uftqtp-everything-about-object-repository/






UFT/QTP : Everything About Object Repository


This article talks about the object repositories, how to create and use one.
Image 1
ObjectRepository
To start with lets understand what does the Object repository holds ?
It is a utility that comes with UFT/QTP that stores all the screen object with its properties that will be used by the script to identify and work on it. By objects I mean anything that is visible on the application, may be an image, text field, list items, texts etc.
When you start recording, as you perform steps on the application it learns the properties of the objects and start storing it in Object repository. All the objects added while recording gets added to the Object repository local to that action.
The image below shows what is there in Object repository.
Image 2
ObjectRepository1
a. Object Identifier : Every object that gets added has a Object Identifier. Object Identifier works in the same way as a name given to any person in order to identify them. This is being used by the test script to work on the objects.
b. Object Class : There are different kinds of objects like text field, Combo box etc. The objects have this value assigned based on their type. Like if the application is a web based application and the object is a edit field, the class will be “WebEdit”. QTP/UFT has its own list of classes for different object categories. To look at the list you can open Object Identification wizard.
Navigation : Tools Menu -> Object Identification..
Image 3
ObjectIdentification
This wizard defines which all properties which will be added to store the objects in object repository to uniquely identify them. It can be modified if needed. I have discussed about it in details in another post.
c. Object Location : It defines where the object is stored, if its a part of local object repository or Global object repository.
d. Object Properties : These are the properties which are used to identify the object in application. This come from the Object Identification window. As you see in Image 1 that there are three properties listed type,name and html tag to identify the object “q”. This list of properties comes from the Object Identification settings.
Image 4
ObjectIdentification1
In image 4 you see for WebEdit class we have 3 properties listed under “Mandatory Properties” which is same as the ones used in Object repository.
e. Visual Identifiers : This is used to enhance the object identification and reduce the risk of false object recognition. It is a set of definitions that helps to identify the objects using its relative location to the neighbouring objects. So in this case you select the neighbouring objects that will have same relative position to the object we are working on. The purpose is to have more reliable object identification.
f. Ordinal Identifiers : These are the properties that is used in addition to the mandatory and assistive properties to identify the Objects uniquely.
For example Suppose you have two test fields with the same type,name and html tag and even the assistive properties matches, In this case it will add the Index ordinal identifier to recognize the object uniquely.
There are three kinds Ordinal Identifiers:
1. Index : Indicates the order in which the object appears in the application code relative to other objects with an otherwise identical description. It starts with 0. So the first object will have index 0.
2. Location : Indicates the order of object in its parent window, frame or dialog. The first occurrence is 0.Values are assigned for this ordinal identifier from top to bottom and left to right.
3. Creation time : This is used for the Browsers only. Indicates the sequence in which the browser is opened. The browser opened first has the assigned value 0.
Object Repositories are of two types :
1. Local Object repository(.mtr file extension):
This is just available to a action. The objects added to the local Object repository can not be used in any other action, even if they are the part of same test.
To open Local Object repository navigate to Resources Menu -> Object Repository or press Ctrl + R on the keyboard. Whenever the recording starts it add the object in the local Object Repository associated with the same action. Or you can even add the objects manually.
2. Shared Object repository (.tsr file extension): It has a global scope and the object repository can be used by any number of actions in different tests. To create one you can open “Resources ->Object Repository Manager -> File -> New”
Image 5
ObjectRepositoryManager
In order to use the object in shared object repository you need associate it with the actions. It can be done using “Associate Repositories” wizard.
Image6
AssociateRepository1
After you have added object to the global library you can save it in ALM or local machine. Now you can browse it using “Associate Repositories” wizard and get access to the object available.
For example if you open local Object Repository now, you can see both the local object and the Objects that are in shared Object Repository as shown in the image below. Object “Google” is an image that is present in the global Object Repository and “q” is an edit field present in Local Object Repository.
Image 7
ObjectRepository2
How to handle properties which are dynamic ?
There is an option to replace the property value with a Repository parameter. In this way you can handle the dynamic values for the properties.
In order to do so you need to select the property you want to parameterize and then Select “” button on the right side. You get the window “Repository Parameter”
Image 8
RepositoryParameter1
Image 9
RepositoryParameter2
The value can be a constant that is the same value as before. If you want you can add regular expressions to it.
Regular expression : It is a way to define the search criteria for the string. You can use special characters such “.”, “*”, “[]” etc to define the same.
For example : If you select “Regular Expression” checkbox and add “.*” to your string. So it will search for an object that has “alt” property starting with text “Google” and can have any number of characters after that.
Second way is to select the parameter from the datatable/Environment/Random Number. You can select the radio button “Parameter” and make appropriate settings.
Image 10
RepositoryParameter5
Reference : UFT/QTP help file

1 comment:

  1. In the object Repository for an object, Properties and Values displayed in Object Properties window(first look, before going to + sign), Are those the only properties and values that QTP will use to detect that particular object?

    ReplyDelete