QTP Tutorial #8 – Learn About QTP Recording Modes, Object Spy and Object Repositories

In this article we will talk about the different recording modes, Object Spy and Object repositories in QTP.

Recording Modes in QTP:

Recording is the most commonly used method to create a test. The basic steps are typically recorded and the test later under goes improvements in order to suit the needs of the testing process.

QTP provides 3 modes of recording:

  1. Normal
  2. Low-level
  3. Analog

Though only the normal recording mode gets used most of the times, it is important to know the others too, as the knowledge about the same can come handy when the need arises for them.

Normal Recording mode– The default recording method is always the normal mode. In all our previous articles when we say record we meant the normal mode. So, as we know this method uses the model of Test Objects and Runtime objects to learn and act on the AUT.

Analog recording mode– records the exact mouse and key strokes that the user performs in relation to either the screen or AUT window.  The steps that are recorded using this method cannot be edited.

The way this usually gets represented in a code is:

Window/app.RunAnalog “Track1”

One scenario in which this type of recording can be used is when we are trying to capture a signature.

Low Level recording mode- This mode records the co-ordinates in the application where the operation is performed, irrespective of whether QTP recognizes the specific Object or Operation.

Some important points to note about these different modes are:

  1. In the middle of recording, we can switch to Analog/Low-level mode, finish the task required and go back to normal recording
  2. Analog and Low-level recording modes require more memory space than the normal mode.
  3. Mouse movements are not recorded in the low-level recording mode
  4. The switch to Analog mode is available only during recording and not during editing
  5. The test that is recorded in an analog mode will fail if it is run after changing the screen resolution.

The menu option to change the recording mode is:

Change recording mode in QTP

Object Spy:

Object Spy is an extremely helpful tool that QTP has to view the properties and operations of an object in the AUT. The prerequisite to using this tool is that the AUT has to be opened.

The Object Spy can be accessed by using “Tools->Object Spy” or by directly clicking on the below

icon 11

Object Spy in QTP

It is also available from the Object repository and Object repository manager windows.

When Object Spy is launched, this is how its interface looks:

Object Spy launched in QTP

By clicking on the pointy hand you can point to any object whose properties you wish to examine.

This is how it displays the properties:

Object Spy properties

------------

As you can see, it shows all the properties of the object and the corresponding values. It shows the object hierarchy. There is also an ‘Operations’ tab which when clicked displays all the operations that can be performed on the test object:

Object Spy operations

The spy not only displays the properties, it also has a provision that lets the users add a certain object to the OR.

You can do that by clicking on the OR icon with a + in it.

Object Repository

In one of the previous articles we talked about how an OR is like a warehouse where all your objects are stored.

OR has the list of Objects that QTP learned during the record process and the class to which they belong. It stores the set of properties that uniquely identifies the Object (description) and also names the object for the sake of identification in our test, based on its most prominent feature.

The objects that are acted upon during record get automatically added to the OR. Alternately, the user can add additional objects on a need basis. This can be done directly from the OR window or from Object Spy.  (Ctrl+R or Resources->Object Repository or click on the icon.)

There are two kinds of repositories:

  1. Local
  2. Shared

Every time a test is created we have seen that a call to Action 1 is the only statement by default. We can add other actions and call them as needed. So, for every action QTP creates its own local repository by default.  It contains the objects that are related to that particular action.

Conversely, the user may decide to use a common repository for multiple actions in which case, this repository is to be associated with the actions and all of them can share the objects that it contains. This can be done using the “Object Repository manager’. The objects can be exported from a local repository into the shared one to maintain a single location for all the objects.  Also, a shared repository is read-only in the action level and any changes to it have to be made via ‘Object Repository manager’.

The repository to be used by an action has to be specified in the action properties.

How is it done practically is something we will look into using some examples later on.

Some of the important points to note here are:

  1. Even though there is a single shared repository for all actions every action will have its own local repository whether the test uses it or not. For example: For test 1 if there are Action 0, Action 1 and Action 2 and there is a shared repository ORShared, there will be local repositories OR0, OR1 and OR2 by default. However, if all the actions use one shared repository, local OR will be empty.
  2. If a local OR and Shared OR have an object with the same name, the action will consider the object in its local OR.
  3. There can be more than one Shared OR’s associated to the same action. If Shared OR1 and Shared OR2 have one object named OBJ1 each and if the action calls for OBJ1 then the order in which the shared ORs were associated will be considered. That means, if Shared OR1 was first associated then the OBJ1 from Shared OR1 will be taken into account.

It goes without saying that having a shared Object Repository is more efficient as it helps in easy maintenance and you can use one object description across multiple actions.

Here we covered some of the key concepts that will enable us to understand and create better QTP Tests. In my opinion information on Actions, Active screen and a rather impromptu but important password encoder tool are few more aspects we will have to cover before we move to more advanced topics.

This is tutorial #8 in our comprehensive online QTP training series. There are ~30 QTP tutorials in this online QTP training. We hope you will benefit from these to learn QTP.

Recommended reading

10 comments ↓

#1 Abhijit

how many object repositories we can use with one action?

#2 Suresh

can you provide uses of these recording modes? Which recording mode is used and when with example?

#3 Swati

@abhijit: Every action by default will have its local OR. Apart from that you can associate multiple shared ORs to it.

#4 Swati

@Suresh: Typically these recording modes are used when your normal mode is not enough. For example, if you are working on an environment that QTP does not support.

#5 Arun

I have offer in testing as QA Content Engineer ,i don’t know much about the job nature.Can anyone pls help me what will be the job description for this ,and sort whether i will have scope in this…..Pls reply any 1 ASAP bcoz i have interview tomorrow

#6 Indira

hi,
can you please explain about Action 0 and difference between Action 0 and Action 1

#7 Akhil

@Indira: Actions are nothing but reusable components where we can use the Actions for several times by specifying (Example:we will name them as Action0 , Action1,etc.)

In detail:
?It increases readabilitaly i.e., instead of reading the total script, that can read action by action.
?Debugging is very easy i.e., finding logical errors in the script.
?Make code reusable.
?Scripts are easy to maintain.
?Saves development time.
?Scripts are efficient.

#8 nilesh

can you please let me know how we can share the repository.. i mean when we record or create script we will create local repository for that action but then how we can share it with the other action or TEST. is there any option somewhere?

#9 Rahul

Can someone please tell me how many shared object repositories a single qtp test(not an action) can have?

#10 Akanksha

I have a query.An object spy identifies the property of an object which we explicitly wants to add in OR.Which all properties it identifies out of Mandatory,assertive or Ordinal identifier?

Leave a Comment