Blog to understand automation concepts in QTP, Selenium Webdriver and Manual Testing concepts

Showing posts with label Object Identification. Show all posts
Showing posts with label Object Identification. Show all posts

Ordinal Identifier in QTP

While learning the objects, QTP tries to identify objects based on the mandatory and assistive properties of the object. In case the above properties are insufficient to uniquely identify the object. QTP uses the ordinal identifier properties to uniquely identify the object together with the madatory and assistive properties.


There are three type of Ordinal Identifier in QTP which are assigned as numeric integer value for the object based on the order occurrence of object in the browser.


The three types of ordinal identifier are described below:



Ordinal Identifier

Description

 Index Based

Based on the object in the window, An index value is assigned to object based on existence in the source code. Index value starts from 0.

Location Based 

The Location property is based on location of object, works vertically from top to bottom and then from left to right. value starts from 0.

Creation Time

The Creation Time property is used for browser objects mainly and used to identify multiple browsers based on the time the browser/page was open. Value starts from 0

Properties for object identification in QTP

QTP learns the properties of test objects to uniquely identify the object at run time. There are predefined set of properties for object classes in each environment.


Object are classified as Object classes for each environment. For e.g. environment Standard Windows environment as shown below will have all the test object class defined and defined are the mandatory and assistive properties to identify the object. Also we can set smart identification On for the object and the default ordinal identifier.to identify the object. 


To have a look at Object Identification properties for an object, Navigate to Tools>Object Identifier.


Let us understand the object Identification Window:


1. Environment: Lists all the environment for which objects are defined.


2. Object Classes:
List all the controls available for the environment selected.


3. Mandatory Properties:
These are the properties QTP always learns for the test object class selected.


4. Assistive Properties: In case object is not uniquely identified using the mandatory properties, there are some assistive properties which are learned to uniquely identify the object.


5. Smart Identification
is false by default, but can be checked for identification.


6. Ordinal Identifer: In case object is not identified using the above properties , Ordinal identifier is used to identify the object

Understanding Object Repositories Manager: Managing Objects

1.  How to Import Object Repository from xml file


Object repository can be loaded from an external xml file using object repository manager.


Importing and exporting Object Repositories to/from xml file


2.  How to export Object Repository to a xml file


Object repository can be exported to an external file using object repository manager.


3. Defining Objects manually in object repository 


      A new test object can be added manually using object repository manager. Below are the steps to add object manually in the object repository

Adding Object manually in Object repository

  • Navigate to Resources>Object Repository Manager
  • Navigate to Object>Define New Test Objects
  • Define new test Object with environment, name, and class of object and add description properties to object.
  • Click on Add to add object.
  • Save object repository as shared object repository


4.       Add Object to repository

  • User can add an object from  application without recording
  • Navigate to Resources>Object Repository Manager.
  • Navigate to Object>Add Objects
  • Focus on object to be added and click.
  • Object is added to repository.


5.       Navigate and Learn

  • User can add required objects from application using Navigate and Learn.
  • Navigate to Resources>Object Repository Manager.
  • Navigate to Object>Navigate and Learn or press F6.
  • Define the filter for objects to be added.
  • Click on learn button.
  • Object will be added to object repository


·          
Options of Working with object

6.       Update Object from Application

  • User can update objects from application with below steps
  • Navigate to Resources>Object Repository Manager.
  • Select an object to be updated. Please note updated object class should be same as the class of object by which it is to be updated.
  • Navigate to Object>Update from application
  • Object properties are updated

Creating a visual relation Identifier for object Identification

A visual relation identifier is a set of definitions that enable you to identify the object in the application according its neighboring objects in the application. Virtual relation identifier can be useful to identify objects that are not uniquely identified using object properties but can be identified based on relative position of other stable and uniquely identified objects in the application.


Creating a visual relation identifier for an object


1. To create a visual relation identifier for an object, go to object repository window and select the object for which visual relation identifier needs to be created.

2. In the Visual Relation Identifier Settings row, click in the Value cell.

3. Click the Browse button in the text box

4. Define relation of object relative to other objects.


Visual relation identifier


Some Important points to remember about visual relation identifier are:


1. Visual relation identifier are taken into consideration if object is not uniquely identified using the object identification Properties.

2. Visual relation identifier have preference on smart identification for object recognition.

3. Ordinal Identifiers are ignored if visual relation identifier is defined for an object.

4. Visual Relation identifier are created for an object based on relative position of other stable object, i.e. objects existing left, right, top , bottom relative to object to be identified can be used for relative identifier.

5. Relative Objects should exist in object repository before a relation can be created.

6. Relative visual identifier cannot be used in Descriptive Programming as objects should exist in OR.

7. This is used to filter in case of multiple objects in the application matching object definition but are placed relative to other object in application.

8. If no objects in the application match the test object’s description properties, then the visual relation identifier you defined is ignored.

9. Visual relation identifiers are not supported for WebService test objects.



Object Repositories in QTP:Understanding Types and Collection Object.


Object Repository stores all the objects learned in the application. An Object repository is automatically created when we record in the application. Object can also be added in object repository through object spy and Navigate and Learn objects.

Following are important points to remember about object repositories:

  • Objects are stored in tree structure in OR with child objects linked to parent objects.
  • Objects in Local OR and shared OR can be accessed/modified through Object Repository window and Object repository manager window respectively.
  • Objects in OR can be added through:
o    Recording mode
o    Active screen
o    Using Object Spy
o    Using Navigate and Learn through Object repository window.
  • Objects can be added with expected properties defined manually in OR. This is useful in case application is not ready, but we know the expected property for objects.
  • Copying or moving an object to be a child of a bottom-level object in the object hierarchy is not allowed.
  • Property value and name of object in object repository can be modified.
  • Modifying the name of a test object in the local object repository is automatically updated in both the Keyword View and the Expert View for all occurrences of the test object.
  • We can highlight objects from OR in application.
  • Object from object repositories can be dragged and drop in the expert view. Hierarchy Tree of the object is visible in expert view on dragging object from OR.


There are two types of Object Repositories:


1. Local Repository

Objects are automatically added in Local Object Repository once they are learned from the application.

Following are important points to remember about Local Object Repository:

  • If an object with the same name is located in both the local object repository and in a shared object repository associated with the same action, the action uses the local object definition.
  • Local Object Repository is associated with the action in which it was created. You cannot associate Local object repository with multiple actions. Due to this, they are useful mainly in single action.
  • If child objects are moved from shared OR to local OR, parent objects are also added to Local OR.


2. Shared Object Repository


A shared object repository stores objects in a file that can be accessed by multiple tests (in read-only mode).

Following are important points to remember about Local Object Repository:

  • Same Shared Object repository can be added for multiple actions.
  • Shared OR can be dynamically associated with tests and multiple actions.
  • Shared OS is saved with extension .tsr
  • Objects from local OR can be exported to shared OR.
  • An Action can have multiple Shared object repository associated.
  • A shared repository can be edited by one person at a time and is locked for other user
  • Using OR comparison tool, we can compare the objects in 2 different shared OR
  • Using Object repositories Merge tool, we can merge two shared OR and create a new OR with objects from both the OR’s.

Associating Repositories with Action

We can associate object repositories with action in following ways:

Through QTP Interface


Navigate to Resources>Associate Repositories. Click on + icon and select repositories. Note we can add shared object repository only. Next Select Actions from available Actions and move required actions to Associated Actions.



Associating Repositories with Actions
























Using Object Repositories collection


We can add object repositories using ObjectRepositories Collection

Below code snippet shows how to add ObjectRepositories using QTP AOM

Public Function func_AddORToTest(TestName, ActionName, ORName)
''Create an object of qtp
Set qtApp = CreateObject("QuickTest.Application")
qtApp.Launch
qtApp.Visible = True

qtApp.Open TestName
Set qtRepositories = qtApp.Test.Actions(ActionName).ObjectRepositories


' Add MainApp.tsr if it's not already in the collection
If qtRepositories.Find(ORName) = -1 Then ' If the repository cannot be found in the collection
qtRepositories.Add ORName, 1 ' Add the repository to the collection
End If
'Save the test and close QuickTest
qtApp.Test.Save
qtApp.Quit 


Set qtRepositories = Nothing
Set qtApp = Nothing

End Function

Object Identification in QTP - Learning Objects


During run time QTP matches the object properties it store during test preparation and perform the required action on the object identified.In this article, we will discuss how objects are identified in QTP.

Learning an Object


1. When we work on an object, QTP stores it as a test object and assign class to the object to which it belongs, For e.g: webEdit, WebElement.

2. QTP considers the mandatory identification property for the object based on the class to which the object belongs.

3. If it is not able to identify unique object in the page using mandatory properties, it adds assistive properties one by one until a unique identification is created.

4. It then adds ordinal identifier if identification properties (defined in 2 and 3) are not unique to identify object. Ordinal Identifier indexes the object based on Location, Creation time or index of the object in the page.

5. We can also define Visual relation identifier. Visual relation identifier defines an object based on relative position of the object relative to other objects in the page. For details on this, please refer QTP user guide.

6. We can also enable Smart Identification for the object in the object repository.


As explained in step 1-6 above, identification for object are created and saved in the object Repository.

An object can be learned in object Repository in following ways:

1. During recording session.

2. Using Object spy.

3. Learning from object repository Tool.


All the child objects can be learned based on the parent object using Object Spy.

Identification of object during run session:


Once we have learned the entire objects, an object repository containing all required objects is created.
During Run-session, QTP looks to identify unique object matching the object definition from object repository. Once it finds the required object, it performs action on particular object.

The object is identified during run session in following way:


1. It looks for identification properties (mandatory and assistive properties) in the run object.

2. In case more than one object matching the identification properties is found and visual relation identifier is defined, it search to identify the object using virtual relation identifier.

3. In case unique object is not found in step 1 and 2, QTP uses smart identification to identify the object.

4. In case using above steps, if object is not identified and virtual relation identifier is not defined, it looks for ordinal identifier properties.


Using above steps, QTP determines if the object is identified in QTP

Brief about Terms used:


Visual relation identifier

Visual relation identifier defines an object based on relative position of the object relative to other objects in the page.

Smart Identification

In case, QTP is not able to identify unique object based on identification properties and smart Identification checkbox is selected, it forgets learned properties and tries to identify the unique object based on Base Filter Properties and optional filter properties defined in smart identification. It searches for all objects matching the base filter properties and filter out objects based on optional filter property one by one, until a unique object is found.

Ordinal Identifier

The ordinal identifier assigns the object a numerical value that indicates its order relative to other objects with an otherwise identical description. Index, Location, and Creation time are different types of ordinal Identifier. Creation Time is browser specific only.