Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE
Highlighted
Absent Member.. bobando Absent Member..
Absent Member..
311 views

QTP/UFT Support Tip: How to add objects to an object repository programmatically?

Hello everyone,

 

As there is no built-in method to programmatically add objects to the object repository, a workaround can be implemented. You can use the Automation Object Model (AOM).

 

The following example illustrates how to create a new Test Object, set its properties, and add it to the shared object repository:

 

' Create a Repository object reference

Set Repository = CreateObject("Mercury.ObjectRepositoryUtil")

 

' Load the specified Object Repository file.

Repository.Load "C:\empshared1.tsr"

 

Create a new Window Test Object for the Notepad Window and set the properties for the object

set WinObj = CreateObject("Mercury.StdWindow")

WinObj.SetTOProperty "is owned window", False

WinObj.SetTOProperty "is child window", False

WinObj.SetTOProperty "regexpwndtitle", "Notepad"

WinObj.SetTOProperty "regexpwndclass", "Notepad"

WinObj.SetTOProperty "text", "Untitled - Notepad"

 

' Add the Notepad Window object to the Repository file.

Repository.AddObject WinObj, NULL, "Notepad"

 

' Create a new WinEditor Test Object for the Notepad editor and set the properties for it.

set EditObj = CreateObject("Mercury.WinEditor")

EditObj.SetTOProperty "nativeclass", "Edit"

 

' Add the Editor object to the Repository file under the Notepad window.

Repository.AddObject EditObj, WinObj, "Edit"

 

' Save the Repository file

Repository.Save

 

' Release the object references

Set WinObj = Nothing

Set EditObj = Nothing

set Repository = Nothing

 

msgbox "Object Repository Update Done"

 

 

I hope this helps.

 

Thanks

HP | Unified Functional Testing Engineer

[If this post or any other post helps to resolve your issue or query, mark the thread as solved and give KUDOS to the author for their assistance. ]

(Posts and opinions made here are my own and do not reflect the opinions of my employer HP in any way)
Labels (2)
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.