Have you ever got frustrated with the arbitrary names QTP gives to test-objects?
When you want it to take the name from the “HTML ID”, it takes it from the the object’s “CLASS”; when you want it to take the “PROG ID”, it takes it from the “NATIVECLASS”; and in general, it seems that QTP has a very poor logic when it comes to choosing Test-Object names.
Actually, QTP has a very good logic, it’s just that it works based on the assumption that, on the average, the resulting names would reflect the meaning the developer wished to convey with the values of these properties. However, because of this same reason QTP is bound to fail in some applications. Luckily, we can override it and hence force QTP to name objects according to the properties we choose.
In order to change the way objects are named, make sure QTP is closed, open the registry editor, and navigate to the following entry:
HKCU\Software\Mercury Interactive\Quicktest Professional\MicTest\Test Objects\ (HKCU means HKEY_CURRENT_USER)
Under that registry node, you’ll find keys for each and every test-object class in QTP. Expand the one you wish to change (For example: Browser).
You will notice that the key has a string value property called “tag query name” – change it to a name of a property (for example – title). The current value (“logical name”) doesn’t correspond to a specific property, but is probably an algorithm for trying several properties until hitting a meaningful value.
After that, open QTP, and record an object from the class you have just changed. You will see that its name is derived from the property you have specified.
And there you have it. I hope this will help you to work more smoothly with QTP, and save you the often tedious task of editing the object identification properties for better readability and maintainability.

Yaron Assa




November 18th, 2008 at 12:34 pm
Thanks, Yaron. Excellent tip. A colleague and I were wondering about the algorithm used for naming objects but it didn’t occur to me that the items were held in the registry.
Did you find this information via documentation or were you scouring the registry for interesting entries from which you derived this tip? If it was the former can you point me in the direction of the documentation.
Cheers,
Mike
November 18th, 2008 at 11:04 pm
Nice tip…it will help to customize object naming if its not conisent through out applcation……
November 20th, 2008 at 5:50 am
This is something that has annoyed me for a long time and now I can fix it! Thanks for the tip.
November 26th, 2008 at 9:41 am
Great tip to tackle annoying naming mechanism of QTP.
November 29th, 2008 at 10:50 am
A very nice tip. Thanks Yaron.
December 1st, 2008 at 9:05 am
Mindblowing trick..Thanks a lot.
December 8th, 2008 at 10:36 am
brilliant trick to get useful names in OR.
January 12th, 2009 at 8:51 pm
what is registry editor, i could not find it out,
can u help in this
January 12th, 2009 at 10:42 pm
You can find it under
Start->Run
and type
Regedit
However, if you’re unfamiliar with the tool, it might be best to leave these things as they are.
January 29th, 2009 at 4:41 pm
this is an excellent trick…. It really worked in local system.
But what happens if i run the same script in another machine without using this modified registry?
June 11th, 2009 at 7:54 am
Superb trick Assa
June 15th, 2009 at 7:26 am
Thanks Yaron. It is very helpful and reduce the time to work on naming conventions. Thanks a lot for giving superb trick.
July 10th, 2009 at 9:49 pm
Have others used this trick? How is it working for you. Are there other articles on this topic?