A visual relation identifier (VRI) is a set of definitions that enable you to identify the object in the application according its neighbouring objects in the application.
You can select neighbouring objects that will maintain the same
relative location to your object, even if the user interface design changes.
This helps UFT to identify similar objects much as a human tester would, and helps in creating more stable object repositories that can withstand predictable changes to the application’s user interface.
Scenario1:- You need to go to Cash counter (Object) in bank; your friend told you that it is the third counter from entry.
Solution :- You( UFT )enters the bank, looks for Cash counter name, but sadly there are two Cash Counters one for deposit and other for withdrawal , you are confused which is the counter you have to go, than you thought of going to the third counter from entry (Ordinal Identifier concept of object identification in UFT) but bad luck again, due to some renovation in Bank, cash counter has been moved to different location, so you as UFT failed to identify the object.
To overcome the limitation of Scenario1, UFT comes with the feature VRI (Introduced in QTP -11.0).
Scenario 2:- In addition to scenario1, UFT is told that cash counter (Object) has Bank Manager Cabin on left and in the same horizontal line.
Solution: – UFT enters the bank, looks for the Cash counter name, but as there are two counters with the same name, now comes VRI, i.e. to look for that counter which is left of Managers cabin and finally right(Unique) counter is found.
Now here even renovation happens than also UFT will uniquely identify counter (with the assumption that in case of renovation also Managers, Cash counter will remain adjacent to each other irrespective of their position(Ordinal Identifier) in Bank.)
In testing also lot of time object position changes (Renovation happens) so VRI is more reliable than Ordinal identifier, provided that relative objects are same.
Place to ser VRI:-
You define visual relations in the Visual Relation Identifier dialog box, which is accessible from the local or shared object repository, and from the Object Properties dialog box
VRI usage in UFT:-
Step 1:- During a run session, UFT first attempts to identify the test object (Cash Counter)using the object’s description properties(Mandatory + Assistive Properties).If it fails to uniquely identify than VRI comes into picture.(Provided VRI is enabled)
Step2:- If UFT finds one or more objects matching the test object’s description, it attempts to identify the object using the VRI.