Monday, 15 August 2011

Object Repository

Software objects 
 We call windows, Web pages, edit boxes, check boxes, buttons etc. as software objects.

Types of object in QTP
  •  Runtime Objects
Run-time objects are created and maintained during a QuickTest run session by the object creator (for example, Microsoft for Microsoft Internet Explorer objects, Mozilla for Mozilla Firefox objects, the product developer for ActiveX objects, and so on). During a run session, QuickTest performs the specified test object method on the run-time object. Run-time objects are not stored in an object repository, as they are available only during the run session.

  • Test Objects
Test objects are stored representations of the actual objects (or controls) in your application. QuickTest creates test objects by learning a select set of the properties and values of the objects in your application. QuickTest uses the information it learns to uniquely identify the run-time objects in your application.
Each test object is part of a test object hierarchy. For example, a Link object may be part of a Browser/Page/Link hierarchy. Top-level objects, such as Browser objects, are known as container objects, as they can contain lower-level objects, such as Frame or Page objects.

  • Utility Objects 
They are QTP reserved objects. Reserved objects are not learned or stored in the object repository. Reserved objects enable you to retrieve or control QuickTest settings or to modify QuickTest behavior during a run session.
Eg:
  1. Reporter Object : The object used for sending information to the run results.
  2. Services Object : Enables you to control and monitor how your test runs in conjunction with LoadRunner, Astra LoadTest, or Business Process Monitor.
  3. Environment Object : Enables you to work with environment variables. You can set or retrieve the value of environment variables using the Environment object. You can retrieve the value of any environment variable. You can set the value of only user-defined, environment variables.
  1. SystemUtil Object : An object used to control applications and processes during a run session.
  2. Desktop Object : An object that enables you to access top-level items on your desktop.
and so on….

  • Automation 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 objectclass, excel. Application class etc.


Object Repository

Objects can be stored in two types of object repositories—a shared object repository and a local object repository.

A shared object repository (.TSR extension) stores objects in a file that can be accessed by multiple tests (in read-only mode). You can use the same shared object repository for multiple actions. You can also use multiple object repositories for each action. 

  • You can use the same shared object repository with multiple actions, instead of saving objects directly with an action in a local object repository. This enables them to be accessed from multiple actions.
  • You can use multiple shared object repositories with each action.
  • If your shared object repositories are stored in Quality Center, you can apply version control to them.

A local object repository (.MTR extension) stores objects in a file that is associated with one specific action, so that only that action can access the stored objects.
Tests always use the object repositories that are specified in the Associated Repositories tab of the Action Properties dialog box or in the Associate Repositories dialog box. Shared object repositories are read-only when accessed from tests; you edit them using the Object Repository Manager.
You perform many object repository-related tasks either in the Object Repository window or in the Object Repository Manager.

Deciding Whether to Use Local or Shared Object Repositories
To choose where to save objects, you need to understand the differences between local and shared object repositories.
The following table describes when it is preferable to use each type of object repository:

Use this object repository type...
In these situations...
local object repository
  • You are creating single-action tests.
  • You are creating simple tests, especially under the following conditions:
  • You have only one, or very few, tests that correspond to a given application, interface, or set of objects.
  • You do not expect to frequently modify object properties.
  • 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
  • You are creating tests using keyword-driven methodologies (not by recording).
  • You have several tests that test elements of the same application, interface, or set of objects.
  • You often work with multi-action tests and regularly use the Insert Copy of Action and Insert Call to Action options.
  • 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.
  • 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.
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.


Operations on Object Repository
  •    Adding Objects
 Objects can be added to the object repository in the following 3 ways:

1)  After clicking an object you can add it (or any other object in the Object hierarchy tree) to the object repository using the Add to Repository button . If the object is successfully added to the object repository, the repository icon is added to the bottom of the test object icon.

Note:
  • When the Object Spy dialog box is opened from QuickTest or the Object Repository Window, the object is added to the local object repository of the active action or component.
  • When the Object Spy dialog box is opened from the Object Repository Manager, the object is added to the active object repository. This option is disabled when there is no open repository.
  • If an object in the Object hierarchy tree already exists in a repository associated with the active action or component, a repository icon is displayed in the lower-right corner of the object's icon.

2)

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 thewindow/object>click ok


3)

Adding Test Objects to the Local Object Repository from the Active Screen
You can add test objects to the local object repository of the current action by selecting the required object in the Active Screen.
To add test objects to the object repository using the Active Screen, the Active Screen must contain information for the object you want to add. You can control how much information is captured in the Active Screen in the Active Screen node of the Options dialog box.
When you add a test object to the object repository in one of the ways described in this section, the test object is added to the local object repository and can be used only by the current action. If you want to add the test object to the shared object repository, so that it can be used in multiple actions, add it using the Object Repository Manager (not from the Active Screen).


Right click on the object you want to add to object repository. You will find an option View/Add Object. If you select that option a window as shown in below figure is displayed.

You can add it (or any other object in the Object hierarchy tree).
  • Renaming Objects
When an object changes in your application, or if you are not satisfied with the current name of a test object for any reason, you can change the name that QuickTest assigns to the stored object. You can also provide test objects with meaningful names to assist users in identifying them when using them in test steps.

For example, suppose you have a graphics application in which all the tools in the toolbar are saved as WinObjects in the object repository with the names ToolChild1, ToolChild2, ToolChild3, and so forth. You may want to rename all the buttons to their actual labels to make them easier for you to identify in the test, for example, Color_Picker, Eraser, Airbrush, and so forth.

Renaming a test object does not affect the way QuickTest recognizes the object in your application, as the test object name is not included in the test object description.

If you are working with a shared object repository, your change applies to all occurrences of the test object in all tests that use this shared object repository.

If you are working with a local object repository, your change applies to all occurrences of the test object in the selected action. If other actions in your test also include operations on the local test object, you should modify the test object's name in each relevant action.

When you modify the name of a test object in the local object repository, the name is automatically updated in both the Keyword View and the Expert View for all occurrences of the test object. When you modify the name of a test object in a shared repository, the name is automatically updated in all tests open on the same computer that use the object repository as soon as you make the change, even if you have not yet saved the object repository with your changes. If you close the object repository without saving your changes, the changes are rolled back in any open tests that were open at the time. Changes that are saved are also automatically updated in tests that use the object repository as soon as you open them. To load and view saved changes in a test or object repository that is currently open on a different computer, you must open the object repository or lock it for editing on your computer.

Tip: If you do not want to automatically update test object names in the Keyword View and Expert View for all occurrences of the test object, you can clear the Automatically update test and component steps when you rename test objects check box in the General pane of the Options dialog box (Tools > Options > General node). If you clear this option, you will need to manually change the test object names in all steps in which they are used, otherwise your test run will fail.

Note: 
If you rename test objects in a shared object repository and save the changes, when you open another test using the same shared object repository, that test updates the test object name in all of its relevant steps. This process may take a few moments. If you save the changes to the second test, the renamed steps are saved. However, if you close the second test without saving, then the next time you open the same test, it will again take a few moments to update the test object names in its steps.

Navigation path for renaming:

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
When you remove a step from your test, its corresponding object remains in the object repository.
If you are working with a local object repository and the object in the step you removed does not occur in any other steps within that action, you can delete the object from the object repository.
If you are working with a shared object repository, confirm that the object does not appear in any other action using the same shared object repository before you choose to delete the object from the object repository. Also, confirm that the object you are deleting is not use in a visual relation identifier for another test object.

You delete objects in the local object repository using the Object Repository window, and objects in the shared object repository using the Object Repository Manager.

Note: 
If your action contains references to an object that you deleted from the object repository, your test run will fail.

Navigation path for deleting:

a. Local Repository:
Resources > object repository >select object and right click >choose delete option>confirm deletion> 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 delete option>confirm the deletion>save the file & close repository manager

  •   Associating Object Repositories to an Action
Resources>Associate repositories>click add icon (+)>browse path of therepository>Associate with an action>click ok

  • Exporting Local Objects to a Shared Repository
You can export all of the test objects, checkpoint objects, and output value objects contained in an action's local object repository to a shared object repository in the file system or to a Quality Center project (if QuickTest is connected to Quality Center). This enables you to make the local objects accessible to other actions.

You can choose to only export the local objects to a shared object repository, or to export and replace the local objects. The Export and Replace Local Objects option exports the local objects to a shared object repository, associates the new shared object repository with your action, and deletes the objects in the local object repository.

When you export local objects to a shared object repository, the parameters of any parameterized objects are converted to repository parameters using the same name as the source parameter. The default (mapped) value of each repository parameter is the corresponding source parameter. You can modify the mapping used within your action using the Map Repository Parameters dialog box.

How to Export Local Objects to a Shared Object Repository

This task describes how to export local objects to a shared object repository.
  1. Prerequisites
    1. Open the test that has the local objects you want to export.
    2. Open the Object Repository window by selecting Resources > Object Repository or clicking the Object Repository button .
  2. Select an action 
In the Object Repository window, in the Action box, choose the action whose local objects you want to export.
  1. Export the local objects
Select File > Export Local Objects, or File > Export and Replace Local Objects. The Save Shared Object Repository dialog box opens.
  1. Results 
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 chose 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.

Tip: After you export the local objects, you can use the Object Repository Merge Tool to merge the test objects from the shared object repository containing the exported objects with another shared object repository.

  •  Merging Repositories
This task describes how to merge two shared object repositories according to predefined settings that define how conflicts between objects are resolved.
  1. Prerequisites
    • Determine the shared object repositories you want to compare. You generally merge two shared object repositories that contain objects from the same application, and that may have differences in objects or test object descriptions because the repositories were created at different times or under different circumstances.
    • Make sure that the Object Repository Manager window is open.
    • Make sure the resolution and color settings are configured to match your needs.
  2. Select the Shared Object Repositories to merge
a.       In the Object Repository Manager window, select Tools > Object Repository Merge Tool to open the Object Repository Merge Tool. The New Merge Dialog Box opens.
b.      Specify the two object repository files you want to merge.
  1. Analyze the initial merge results
After the merge is complete, you can view the results summary in the Merge Statistics Dialog Box.
  1. Analyze the detailed merge results
Review and analyze the merge between the repositories in the Object Repository Merge Tool Main Window.
  1. Utilize additional tools to help you perform the comparison (Optional) 
    • Change the view presented by the Object Repository Merge Tool according to your working preferences, by dragging the edges of the panes to resize them, or selecting the appropriate option from the View menu, as described in Object Repository Merge Tool Main Window.
    • Filter the objects and show only the objects that you want to view by using the Filter Dialog Box (Object Repository Merge Tool).
    • Locate one or more objects in a selected object repository whose name contains a specified string using the Find Dialog Box (Object Repository Merge Tool). 
   6. Adjust object conflict resolutions 
If one or more of the merge resolutions does not match your needs, follow the steps below to adjust them: 

In the target object repository, select an object that had a conflict, as indicated by the icon to the left of the object name. The conflicting objects are highlighted in the source object repositories. 

A description of the conflict and the resolution method used by the Object Repository Merge Tool is described in the Resolution Options pane. A radio button for each possible alternative resolution method is displayed.
    1. In the Resolution Options pane, select a radio button to choose an alternative resolution method. The target object repository is updated according to your selection and redisplayed.
    2. In the Resolution Options pane, click the Previous Conflict or Next Conflict buttons to jump directly to the next or previous conflict in the target object repository hierarchy.
       
      7. Save the target object repository
When the object conflicts are resolved satisfactorily, save the new merged shared object repository. QuickTest saves the object repository with a .tsr extension in the specified location and displays the file name and path above the target object repository in the Object Repository Merge Tool window.
If you are connected to Quality Center, you can save your merged shared object repository in the Test Resources module of your project.
  1. Associate the target object repository with actions
You can now associate the new merged object repository with actions, especially ones that were previously associated with the original object repositories, so that the objects in the object repository can be accessed by the tests.

  •   View Menu Options in Object Repository Window
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 specifiedobject in the repository.

Highlight in Application
This feature can be used for identifying objects from repository to application.
Navigation: Select object in the repository >view>highlight in application>it highlightsspecified objects in the application.

  • Spying Objects

Object Spy Dialog Box

This dialog box enables you to view the native properties and operations of any object in an open application, as well as the test object hierarchy, identification properties, and operations of the test object that QuickTest uses to represent that object.
You can also check if an object is in a repository associated with your action or component (via its application area), add the selected object to the local object repository (or a shared object repository if you are using the Object Spy from the Object Repository Manager), and highlight an object in the application.

To access
Use one of the following:
  • Select Tools > Object Spy.
  • Click the Object Spy toolbar button .
Available from:
  • QuickTest Main Window - User Interface
  • Object Repository Window
  • Object Repository Manager Main Window

User interface elements are described below:

Option
Description
Pointing Hand. Turns the mouse pointer into a pointing hand. Use the pointing hand to highlight or click the object whose properties and/or operations you want to view.
  • As you move the pointing hand over the objects in the application, the objects are highlighted in the application (in some environments), and their details are displayed in the Object Spy dialog box.
  • To capture information about a particular object and its parent objects in the Object Spy, click on the object in the application.
Keep on Top. Keeps the Object Spy dialog box in view while spying on an object in your application.
Note: When the Keep on Top button is not pressed, the Object Spy dialog box may be hidden on your screen behind your application. To view the Object Spy dialog box, press the left Ctrl key and arrange the windows as needed.
Highlight in Application. Highlights the object in the application that corresponds to the test object currently selected in the Object Spy.
Add Object to Repository. Adds the test Object selected in the Spy hierarchy tree to the object repository.
  • If the object is successfully added to the object repository, the repository icon is added to the bottom of the test object icon.
  • When the Object Spy dialog box is opened from QuickTest or the Object Repository Window, the object is added to the local object repository of the active action or component.
  • When the Object Spy dialog box is opened from the Object Repository Manager, the object is added to the active object repository. This option is disabled when there is no open repository.
Copy Identification Properties to Clipboard. Copies all of the properties and values for the object currently selected in the Object hierarchy tree. You can paste the copied data from the Clipboard into any document.
Enabled only when the Identification radio button is selected in the Properties tab.
The copied properties and values are formatted in standard programmatic description syntax with line breaks between each property-value pair. For example:
"Class Name:=Image",
"abs_x:=585",
"abs_y:=573",
"alt:=Specials",
....
This option is useful if you want to:
  • Compare the properties and values of two objects in your application.
  • Copy the relevant strings when creating programmatic descriptions.
Object hierarchy
Displays the hierarchy of test objects that are related to the object you selected in your application.
  • If an object in the hierarchy already exists in a repository associated with the active action or component, a repository icon  is displayed in the lower-right corner of the object's icon.
  • To view properties, values, or operations for another test object in the Object hierarchy tree, select that test object in the tree.
  • While an object is highlighted in the application, test object classes are displayed in the Object hierarchy tree, but test object names are not. Test object names (such as Atlanta to Las Vegas and Specials in the image shown above) are displayed only after clicking the object to capture the information in the Object Spy.
Properties tab
Select the Native or Identification radio button to display the native properties and their values, or the test object identification properties and values of the run-time object associated with the selected test object in the Object hierarchy tree.
  • Properties. Displays the identification or native property names for the test object that is currently selected in the Object hierarchy tree.
  • Values. Displays the identification or native property values of the relevant object in the application.
Operations tab
Select the Native or Test Object radio button to display the native operations or test object operations, and their corresponding syntax, for the test object that is currently selected in the Object Spy test Object hierarchy tree, or the run-time object associated with it.
Selection
The content in this box differs depending on which tab is displayed above it.
Properties tab: Displays the property name or value that was most recently clicked.
Operations tab: Displays the syntax of the most recently clicked operation.
Tip: To copy the text that is displayed in this box to the Clipboard, highlight the text and press Ctrl+C or right-click the highlighted text and select Copy.
Description
Provides a description of the most recently clicked operation, when available.

  • Importing and Exporting Repositories using XML

There are 2 ways:

1)

ExportToXml Method:

Description

Exports the specified object repository to the specified XML file.

Important Information

·          This method can be used only to export shared object repositories (*.tsr files).  Local object repositories cannot be exported.
·          The object repository you want to export must be in QuickTest version 9.0 or later format. If the object repository is in an earlier format, you can use the Convert method to convert it before exporting it.

Syntax

object.ExportToXML (SourceFile, TargetFile)

Syntax Details

ArgumentArgument

Description

Object

An expression evaluating to an object of type ObjectRepositoryUtil.

SourceFile

Required. A string value. The full name and path of object repository you want to export to Xml.

TargetFile

Required. A string value. The full name and path of Xml file to which you want to export the object repository. The Xml file must be a new file (one that does not already exist). The folder path must be an existing one.

 


Return Type

A Variant value.  The full name of the new XML file


ImportFromXml Method:

Description

Imports the specified XML file to the specified object repository.

Important Information

This method can be used only to import XML files into new shared object repositories (*.tsr files).  It cannot be used with local object repositories.

Syntax

object.ImportFromXML (SourceFile, TargetFile)

Syntax Details

ArgumentArgument

Description

Object

An expression evaluating to an object of type ObjectRepositoryUtil.

SourceFile

Required. A string value. The full name and path of Xml file you want to import into the new object repository.

TargetFile

Required. A string value. The full name and path of the new object repository to which you want to import the Xml file. The object repository file must be a new file (one that does not already exist). The folder path must be an existing one.


Return Type

A Variant value.  The full name of the new shared object repository.


2)

Exporting Repository to an XML file
We can export our repository file to an xml file.
Navigation: 
Resources>Object Repository manager>File >export Test objects to XML Enter the file name and Save with xmlextension.

Importing Repository from XML file.
We can import XML file to our repository.
Navigation: 
Resources>Object Repository manager>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. Only Shared Object Repositories can be imported and exported.






Defining New Test Objects


Navigation:
Object>Define new test object >Select Environment>Select Class of theobject>Enter name of the object>Click Add>click close>Select object >select propertyname>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.

No comments:

Post a Comment