Below are few awesome Object Repository Interview Questions which you must know before giving any QTP interview:
Define Object Repository in QTP.
Object Repository is used to store objects which QTP learns. Object repository stores things like logical name, properties (identification) etc. of an object.
Define Object Repository Manager.
Object Repository Manager enables you to create and modify single/multiple shared object repositories. You can save the shared object repository to your Quality Center project using the Object Repository Manager. Object Repository Manager helps you to Work with Repository Parameters, merge two Shared Object Repositories, import and export Shared Object Repositories using XML.
Can you export Local Objects to a Shared Object Repository using Object Repository Manager?
No, its done with the help of Object Repository Window.
What are the Drawbacks/Disadvantages of Shared Object Repository?
Multiple users working on Shared Object Repository can’t edit it concurrently.
Any small or big change in shared Object Repository affects all associated test cases.
There MAY be performance issue(s) if size of shared Object Repository is big. For example, if any object is vague / unclear then QTP has to assign some additional properties in order to recognize it uniquely and many other similar issues may slow down Object Repository performance.
Explain Object Repository parameter.
Repository parameters are useful when you want to create and run tests on an object that changes dynamically. As an example suppose there is a button whose text property value changes in a localized application depending on the language of the user interface. You can parameterize the name property value using a repository parameter, and then in each test that uses the shared object repository you can specify the location from which the property value should be taken. For example, in one test that uses this shared object repository you can specify that the property value comes from an environment variable.
In another test it can come from the data table. In a third test you can specify it as a constant value.
Can we update an Object Repository parameter at run-time?
You can set or retrieve the value of repository parameters using the Repository object [An object that enables you to work with repository parameters.]. All changes made to repository parameters using the Repository object are temporary, and are valid only for the current run session.
In order to set the value of a repository parameter use:
Repository (RepositoryParameterName) = NewValue
In order to retrieve the value of an existing repository parameter use:
CurrentValue = Repository (RepositoryParameterName)
How would you load an Object Repository at run time?
Using "Add" Method of RepositoriesCollection, as this 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.
RepositoriesCollection.Add RepositoryPath [, Position]
RepositoryPath is the absolute or relative path of the shared object repository that you want to add and Position Number is the index position to which you want to add the shared object repository in the run-time list of associated shared object repositories. If you do not specify a position, the object repository is added to the end of the list (position = -1).
Explain kind of conflicts that occur when you try to merge two Shared Object Repositories?
An object in the primary object repository could have the same name as an object in the secondary object repository, but have a different description.
An object in the primary object repository and an object in the secondary object repository have the same name, but completely different content.
A test object in the primary object repository and a test object in the secondary object repository have different names, but the same description properties and values.
A test object in the primary object repository and a test object in the secondary object repository have the same name, and they have similar, but not identical, description properties and values.
What type of conflicts can Object Repository Merge Tool identify?
The Object Repository Merge Tool identifies three possible conflict types:
Different Objects with the Same Name Conflict.
Identical Description Different Name Conflict (Test Objects Only).
Similar Description Conflict (Test Objects Only).
For more on this see QTP User Guide.
Explain the types of Object Repositories.
Objects can be stored in two types of object repositories—a shared object repository and a local object repository.
A shared object repository stores objects in a file that can be accessed by multiple tests (in read-only mode).
A local object repository stores objects in a file that is associated with one specific action, so that only that action can access the stored objects.
How do you edit Shared Object Repositories?
Shared object repositories are read-only when accessed from tests; you edit them using the Object Repository Manager.
Explain any one way in which user can know which Object Repository is used by the test?
Tests use the object repositories that are listed in the Associated Repositories tab of the Action Properties dialog box or in the Associate Repositories dialog box.
Which is better - Local Object Repository or Shared Object Repository?
Both Local Object Repository and Shared Object Repository are used in different situations:
Local Object Repository should be used when:
You are creating single-action tests. You are creating simple tests, especially under the following conditions:
1.You have only one, or very few, tests that correspond to a given application, interface, or set of objects.
2.You do not expect to frequently modify object properties.
3.You are new to using QuickTest. You can record and run tests without creating, choosing, or modifying shared object repositories because all objects are automatically saved in a local object repository that can be accessed by its corresponding action.
Shared Object Repository should be used when:
1.You are creating tests using keyword-driven methodologies (not by recording).
2.You have several tests that test elements of the same application, interface, or set of objects.
3.You often work with multi-action tests and regularly use the Insert Copy of Action and Insert Call to Action options.
4.You expect the object properties in your application to change from time to time and/or you regularly need to update or modify object properties.
5.If you are familiar with testing, it is probably most efficient to save objects in a shared object repository. In this way, you can use the same shared object repository for multiple actions—if the actions include the same objects.
6.Object information that applies to many actions is kept in one central location. When the objects in your application change, you can update them in one location for all the actions that use this shared object repository.
Explain difference between Local Object Repository and Shared Object Repository?
Local Object Repository has a file extension .bdb and shared Object Repository has a file extension .tsr. If an object is defined in both Local & Shared Object Repository, QTP gives preference to Local Object Repository. Moreover Shared Object Repository can be shared with multiple actions.
What is better - Object Repository or Descriptive Programming?
Can you drag and drop checkpoint or output value objects from the Object Repository Manager?
No, you cannot drag and drop checkpoint or output value objects from the Object Repository Manager.
Can we move objects from shared object repository to local object repository? Why would you do that?
You can create a local copy of any object stored in a shared object repository that is associated with the action currently displayed in the object repository tree.
Copying an object to the local repository is useful, for example, if you want to alter an object in the present action without affecting other actions that use the shared object repository.
How to Export Local Objects to a Shared Object Repository?
Open the test that has the local objects you want to export.
Open the Object Repository window by selecting Resources > Object Repository or clicking the Object Repository button.
Select an action
In the Object Repository window, in the Action box, choose the action whose local objects you want to export.
Export the local objects
Select File > Export Local Objects, or File > Export and Replace Local Objects. The Save Shared Object Repository dialog box opens.
What is the difference between Export Local Objects & Export and Replace Local Objects?
If you chose Export Local Objects, the local objects are exported to the specified shared object repository (a file with a .tsr extension). Your test continues to use the objects in the local object repository, and the new shared object repository is not associated with your test.
If you choose Export and Replace Local Objects, the new shared object repository (a file with a .tsr extension) is associated with your test, and the objects in the local object repository are deleted. The objects in the Object Repository window are read-only, as they are now in a shared object repository. In the Object Properties section of the Object Repository window, the repository location indicates the path and filename of the new shared object repository instead of Local.
You can now use the new shared object repository like any other shared object repository.
How to Copy an Object from Shared Object Repository to the Local Object Repository?
Open the test containing the action to whose local object repository you want to copy the object.
In the object repository tree of the Object Repository window, select the action associated with the shared object repository containing the object you want to copy.
Select the object that you want to copy to the local object repository.
(Objects in a shared object repository are read-only.) You can select multiple objects as long as the selected objects have the same parent object.
Select Object > Copy to Local or right-click the objects and select Copy to Local. The objects (and parent objects, if any) are copied to the local object repository and are made editable.
While mapping repository parameters, what if you have more than one repository parameter with the same name in different shared object repositories that are associated with the same test?
Before you map repository parameters, if you have more than one repository parameter with the same name in different shared object repositories that are associated with the same test, the repository parameter from the shared object repository with the highest priority (as defined in the shared object repositories list) is used. After you map repository parameters, QuickTest uses the mappings you defined. In addition, changing the priority or default values has no effect after the parameters are mapped.
Is it possible to select a test object in your object repository and see it in the application you are testing?
Yes, QTP has a highlighting functionality. You can select a test object in your object repository and highlight it [Highlight in Application option] in the application you are testing. When you choose to highlight a test object, QuickTest indicates the selected object's location in your application by temporarily showing a frame around the object and causing it to flash briefly. The application must be open to the correct context so that the object is visible.
Explain in short what do you mean by GetTOProperty / SetTOProperty?
After you retrieve a test object, you can manipulate it using the methods and properties available for that test object class. For example, you can use the GetTOProperty and SetTOProperty methods to retrieve and modify its properties.
Can you use regular expressions to specify or modify property values for test objects in the shared object repository?
Yes, you can.
If while trying to add an object to Object Repository, you face some issues e.g. with dynamic objects, is there any tool to assist you then?
You can use object spy to add objects to Object Repository.
For more on Object Repository read HP QuickTest Professional User Guide PDF/ QuickTest Professional Help (.chm file)/ QuickTest Professional Automation (.chm file).