Close

January 31, 2013

Visual Relation Identifiers in HP QTP

In this blog post, we are going to learn about Visual Relation Identifiers in HP QuickTest Pro (QTP). Please check my previous article about how QTP identifies objects during playback for a successful execution.

During playback, QTP identifies each object and assigns ordinal identifier to identify the objects uniquely and to perform actions on it. But, in some instances ordinal identifiers may fail to identify the objects in the screen. So to know, how to identify the objects uniquely, how to define visual relation identifier and how to validate the objects… read further.

What are Visual Relation Identifiers?

Visual Relation Identifiers are set of definitions that enable us to identify the objects uniquely with the help of neighboring objects in the screen. QTP allow us to select neighbor objects that maintain relative location to the object that you are going to identify the required object, even user interface changes.

How to define Visual Relation Identifiers?

Consider below screen which has 9 buttons. Our aim is to identify Click Me 2 button to perform actions on it.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Demo” alt=”Visual Relation Identifiers – Demo” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Demo.gif[/auto_thumb]

So, to identify Click Me 2 button successfully, Button 2 and Button 5 will make an object pair. You need to instruct QTP that Click Me 2 button is right to Button 2 and left to Button 5. During playback, Button 2 and Button 5 will make a pair to identify Click Me 2, even the location of button changes.

To add Visual Relation Identifier, add all the objects and save it as MyObjects.tsr.

  • Open MyObjects.tsr file in Object Repository Manager.
  • Enable the editing mode.
  • Select Click Me 2 button.
  • In the right side, you able to see the Visual relation identifier settings as shown below.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Object Repository Manager”    alt=”Visual Relation Identifiers – Object Repository Manager – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Object-Repository-Manager.gif[/auto_thumb]

  • Click on [None. Click to add] button
  • You get Visual Relation Identifier dialog box as shown below.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Dialog Box” alt=”Visual Relation Identifiers – Dialog Box – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Dialog-Box.gif[/auto_thumb]

  • Click on + button to add the objects to make a pair.
  • You get below dialog box Select Test Object

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Select Test Object” alt=”Visual Relation Identifiers – Select Test Object – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Select-Test-Object.gif[/auto_thumb]

  • There are two ways to add objects. One is by using Object Spy button and another way is by expand the tree view and selecting the appropriate object. Here we have already stored all the required objects (MyObjects.tsr), so it is ideal to use tree view.
  • Here is the expanded view of all the objects.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Select Test Object – Tree View” alt=”Visual Relation Identifiers – Select Test Object – Tree View – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Select-Test-Object-Tree-View.gif[/auto_thumb]

  • Click on Button 2 and then click on OK.
  • In Visual Relation Identifier dialog box, Button 2 will get added. In the right side, check the first checkbox and select Left from the list box as shown below.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Select Test Object – Button 2″ alt=”Visual Relation Identifiers – Select Test Object – Button 2 – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Select-Test-Object-Button-2.gif[/auto_thumb]

  • Because ‘Button 2‘ is to the left of ‘Click Me 2‘.
  • Similarly add Button 5 and select Right as Relation Details.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers – Select Test Object – All Button” alt=”Visual Relation Identifiers – Select Test Object – All Button – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/01/Visual-Relation-Identifiers-Select-Test-Object-All-Button.gif[/auto_thumb]

  • In Object Repository Manager displays that Click Me 2 has visual relation identifier defined. Above screenshot has the additional identifiers which helps to locate Click Me 2.

[auto_thumb width=”150″ height=”150″ link=”” lightbox=”true” align=”center” title=”Visual Relation Identifiers Preview” alt=”Visual Relation Identifiers Preview – QAInsights” iframe=”false” frame=”true” crop=”true”]http://qainsights.com/wp-content/uploads/2013/02/Visual-Relation-Identifiers-Preview-1024×640.png[/auto_thumb]

Visual-Relation-Identifiers-Preview-1024x640

In order to validate the visual relations are defined correctly, click the Preview button. You can now see above screenshot which has related object is getting highlighted to uniquely identify the correct object.

In next post, we will see more about Visual Relation Identifiers.

Thanks for visiting QAInsights!

We’re always posting interesting articles on QAInsights. I request you to subscribe so you don’t miss out anything.

Subscribe to our QAInsights YouTube Channel. Subscribe our free weekly newsletter or Google feeds.

About NaveenKumar Namachivayam

Hi there! is a passionate and experienced Performance Test Analyst based in Chicago, USA with skill sets in Manual Testing, Test Automation, Performance Testing, and Test Estimation. He loves to learn and experiment new trends and models in Software Testing. Please stop by at his personal blogs: Excel Blog, DealsBrook, NaveenKumarN.in, and Affiliate Insights blog and Software Testing Memes.

Leave a Reply

Your email address will not be published. Required fields are marked *