I was just wondering if there is an API for interacting with the object repository?
I have a keyword framework and I want to be able to apply an alias to a QTP Object in a row on an Excel Spreadsheet. Currently I'm copying and pasting the Object Recognition Path out of QTP but it would be better if I could create a treeview that replicates the same tree structure as the Object Repository manager in QTP.
One option is to always export the repository to xml and then read the heirarchy from there, but it would be better if I could read directly from the .tsr file.
I managed to get this working using ObjectRepositoryUtil.
I have attached an example of this to the post - this may be useful if anyone else is trying to do anything similar or is just generally interested.
If you want to give this a try:
1. Load up the spreadsheet and enter the VBA editor (Alt + F11)
2. Open the "modObjectRepository" module
3. Change the "TSR_DIRECTORY" variable to where your .tsr files are saved (it will handle multiple files). Note: put a trailing backslash on the end of this path.
4. Go back to the spreadsheet, click a cell then click on the command button - the treeview is populated with the Object Repository objects.
I'll write this up a bit more on my blog when I get the chance, but feel free to use it yourselves.
A good alternative mechanism to the standard object repository is to use an .ini file. These are easy to interact with from QTP, you can edit them with just about anything, you can easily cut, paste and compare them for version control. They have a simple structure that fits nicely with the requirement. You can see at a glance what code is being used to recognise a given object (it's all based on DP).
For an easy to use test automation framework, checkout my website:
Agreed Bill, that would be another approach. This is working great with my team who at the moment are of junior skill level - we have a keyword framework so when we map an object in the repository we then apply a friendly alias to it. This approach allows them to use the QTP Repository Manager to map objects (easier for them to use and less time consuming than DP) and then a spreadsheet to manage the aliases using the code in the example.