Implementing a custom reserved object

UFT can be extended with additional custom reserved objects. This is a feature that can be exploited to develop objects that are instantiated at the UFT's launch time, making the developer's work much more efficient and the code more concise. In this section, we will describe how to implement GlobalDictionary , which is to be used for data sharing among different Actions.

How to do it…

Proceed with the following steps:

  1. In Windows, navigate to Start | Run. Type regedit.exe and press Enter.
  2. In Registry Editor, search for the folder ReservedObjects. It should appear at HKEY_CURRENT_USERSoftwareMercury InteractiveQuickTest ProfessionalMicTestReservedObjects.
  3. Add a new key and name it GlobalDictionary.
  4. Add the following values to the key:
    • ProgID of type REG_SZ (string value). Assign it the value of Scripting.Dictionary.
    • UIName of type REG_SZ (string value). Assign it the value of GlobalDic.
    • VisibleMode of type REG_DWORD (32-bit value). Assign it the value of 2 (Hexadecimal: 0x00000002).
  5. The Registry Editor window should look as follows:
    How to do it…
  6. Open UFT, and from the File menu, navigate to New | Test, or use the Ctrl + N shortcut.
  7. In Action, type GlobalDic.:
    How to do it…

As you can see, UFT now recognizes GlobalDic in the same fashion as other reserved objects (for example, SystemUtil). The GlobalDictionary parameter (GlobalDic is the UIName we defined in the registry) is already loaded and available, and we also have autocomplete for the syntax of the object methods and properties.

How it works…

UFT takes the definitions of the reserved objects to be loaded from the Windows registry at the ReservedObjects key (as mentioned previously). We defined the progID (the unique identifier for the COM object) as Scripting.Dictionary, which is the UIName to be recognized in the UFT editor, and assigned 2 to VisibleMode (meaning that it should be visible). When UFT is launched, it loads our custom object, together with the other default objects, and it stays in memory until UFT is closed.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset