Just like instantiating classes with the
New keyword, Test Design Studio also simplifies the process of instantiating a new instance of a COM object that is registered and available on your system. This is performed in VBScript through the use of the
To illustrate, type the following text on a blank line in the VBScript document:
Set myNewObj = CreateObject
Now, type the
( character after the
CreateObject function name and you are presented with a dialog to select the ProgID of the item you wish to insert. A list of readily available libraries will be displayed as well as a folder called All Registered Types.
The All Registered Types folder (#1 in the image above) contains references to all the COM objects registered and available on your local machine. Unified Functional Testing also provides some built-in COM objects that are available under the Mercury library grouping (#2 in the image above). Select the Mercury library from the list and the special objects Clipboard and DeviceReplay will be listed.
Now go back to the main list by either pressing the Backspace key or clicking the underlined text Mercury in the popup. This time select All Registered Types and you will be presented with a list of all available types on your system grouped by the library they are contained within. Type or select Scripting.
After applying the selection, the objects available from the Microsoft Scripting Runtime library will be displayed. Select FileSystemObject from the list and press the Enter key to confirm your selection.
The ProgID for the selected item (
Scripting.FileSystemObject) will be inserted to complete the
Below your statement, type the variable name
myNewObj followed by the
. (dot) character. At this point, you would normally expect to see a list of members displayed for the
Note: You should not see a member list at this time. If you do see the member list, you may have previously loaded the corresponding library while using Test Design Studio. Try selecting a different ProgID to continue with the example.
The reason you do not see a member list is because Test Design Studio needs to load the details about the library. You may have already noticed a red box drawn under the
CreateObject function (magnified in the image above). This represents a Smart Tag.
To determine the purpose of the Smart Tag, move your mouse over the red box until the Smart Tag Popup Icon appears (illustrated in the image below). When the popup icon appears, move your mouse over the icon to activate the Smart Tag.
Note: Be careful not to hover over the
CreateObjectfunction or you may display Quick Info for that function instead of the Smart Tag.
The tooltip tells us that the ProgID is not currently recognized by Test Design Studio and instructs us to click for more options.
Click the Smart Tag icon for more options, and we will see the option to Load Reference for 'Scripting.FileSystemObject'. Click this option and Test Design Studio will then analyze the ProgID to determine which library contains its type information, and, if found, that library will be loaded for IntelliSense.
Return to our previous statement where we did not receive a member list for our variable. Delete and retype the
. (dot) character, and we will now properly see a member list for the