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

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

=> Click Here For The QTP Training Tutorials Series

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 undergoes improvements in order to suit the needs of the testing process.

Object Repositories

Learn About QTP Recording Modes

QTP provides 3 modes of Recording:

  • Normal
  • Low-level
  • Analog

Though only the normal recording mode gets used most of the time, it is important to know the others too, as the knowledge about the same can come in 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 said record, we meant the normal mode. 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 keystrokes that the user performs in relation to either the screen or the AUT window. The steps that are recorded using this method cannot be edited.

The way this usually gets represented in the 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:

  • In the middle of recording, we can switch to Analog/Low-level mode, finish the task required and go back to normal recording.
  • Analog and low-level recording modes require more memory space than the normal mode.
  • Mouse movements are not recorded in low-level recording mode.
  • Switch to Analog mode is only available during recording and not during editing
  • The test that is recorded in 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 directly by 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 but 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 recording process and the class to which they belong. It stores a set of properties that uniquely identify 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 the 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:

  • Local
  • Shared

Every time a test is created we see 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 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 a shared one to maintain a single location for all the objects.  Also, a shared repository is read-only at the activity level and any changes to it have to be made via the “Object Repository manager”.

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

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

Some of the important points to note here are:

  • 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 is 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 actions use one shared repository, then the local OR will be empty.
  • If a local OR and Shared OR have an object with the same name, then the action will consider the object in its local OR.
  • There can be more than one Shared OR’s associated with 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. This means that if the 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 a few more aspects that 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 about QTP in detail.

=> Visit Here For The QTP Training Tutorials Series

Recommended Reading

10 thoughts on “QTP Tutorial #8 – Learn About QTP Recording Modes, Object Spy and Object Repositories”

  1. how many object repositories we can use with one action?

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

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

  4. @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. 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. hi,
    can you please explain about Action 0 and difference between Action 0 and Action 1

  7. @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. 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. Can someone please tell me how many shared object repositories a single qtp test(not an action) can have?

  10. 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