QTP Visual Relation Identifier

Overview

Visual Relation Identifier (VRI) is the feature available in QTP (in versions 11 or later) to identify ojbects based on the relative position of the other objects. It helps to identify an object uniquely in the application.

Consider an application where the link “ABC” has many occurences on the same page with all the properties same. There can be some workaround to identify “ABC” present near to section A or inside section B or closer to section C.

VRI makes this job very easy and properties of specific link “ABC” can be set so that it identifies the intended object and not the other occurences of link on the same page.

Use of VRIs:

Example closed to x and y Axis:

Considering the below example where ‘Tags’ is a webelement and below some links appear dynamically.

In automation script, I want to click on the First link below ‘Tags’.

One thing we can observe that Link isclosest to Tags (Visual relation providing uniqueness).

Setting up the VRI in Repository:

Consider we have two objects with logical name ‘FirstLink’ and ‘Tags’ in our repository.

Click on ClickTo Add Section to open the VRI Setting. Click on add object as highlighted.

This should give the list of object present in the repository.

Since our reference object is “Tags”, it is selected and click on OK.

Now provide the relation between tags and Firstlink though relation details section.

Select the appropriate checkbox and condition in the relation details section.

Like We can select link is nearest to tags (Relation1).

We can define multiple relations with multiple objects or same reference object. QTP auto populates the relation between the two objects in the Notes section.

The Same Can be Previewed.

FSO link is highlighted

Click on OK to close the VRI.

Example: Above and Below an Object

URL: http://parabank.parasoft.com/parabank/index.htm

There are two Read More Links on this Page having same properties. There are multiple ways to identify this object namely Ordinal Identifier Index, Descriptive programming, SetToProperty and VRI. This example is by using VRI.

The most relevant object in this case to distinguish between two Read More is Latest News WebElement. How?

ReadMore_First is Coming above of LatestNews_Container

&

ReadMore_Second is coming below LatestNews_Container

The same description can be set in UFT VRI Wizard.

Steps:

Add 3 objects:

ReadMore_First, ReadMore_Second, LatestNews_Container

Then on ReadMore_First click on VisualRelationIdentifier Section:

Click on Add Button and Selection The LatestNews_Container Object:

Select Below for the First Read More object and Above for the Second Read More Object.

Description should Look Like This:

‘LatestNews_Container’ is Below ‘ReadMore_First’; therefore maintaining a relation with the Latest News Container, QTP will be able to find the First and Second Read More object in relation to LatestNews_Container.

Advantages

  • Resolves ambiguity in object identification for similar objects
  • Provides unique position for an object based on the visual settings
  • Much reliable technique as per index based identification
  • Can be used in XML based repository, HP has its schema in the help file.

Limitations

  • Dependency on the Related object for identification, If the Related object is not found in the application or not identified, it will fail.
  • Slow identification – First QTP tries to locate the related object and based on that it goes for identifying the object.
  • Cannot be used using Descriptive programming

Questions for You ?

This is learning and sharing portal, after your initial understanding what do you think should be the answer of below questions ?

  1. What is the use of VRI for Browser test object (meaning a test object of micclass as Browser) ?
  2. Can we use VRI technique to identify object based on the relative position of the object (Reference object) which is present in another repository ?

3)Can we use VRI in descriptive programming approach?

4)Lets say obj1 uses obj2 as the related object, Is there any way that ob1 can act as related object for obj2 at the same time ?