You can register a public function to a test object to enable the function (operation) to be performed on a test object. When you register a function to a test object, you can choose to override the functionality of an existing operation, or you can register the function as a new operation for the test object.
After you register a function to a test object, it is displayed as an operation in the Keyword View Operation list when that test object is selected from the Item list, as well as in IntelliSense and in the general Operation list in the Step Generator (for function libraries). When you register a function to a test object, it can only be called by that test object.
If you choose to register the function to a test object, the Function Definition Generator automatically adds the argument, test_object, as the first argument in the Arguments area in the top-right corner of the Function Definition Generator. The Function Definition Generator also automatically adds a RegisterUserFunc statement with the correct argument values immediately after your function definition.
When you register a function to a test object, you can optionally define it as the default operation for that test object. This instructs QuickTest to display the function in the Operation column, by default, when you or the Subject Matter Expert choose the associated test object in the Item list. When you define a function as the default function for a test object, the value True is specified as the fourth argument of the RegisterUserFunc statement.
If you do not register the function to a specific test object, the function is automatically defined as a global function. Global functions can be called by selecting the Functions category in the Step Generator (for function libraries), or the Operation item in the Keyword View. A list of global functions can be viewed alphabetically in the Operation box when the Functions category is selected in the Step Generator (for function libraries), in the Operation list when the Operation item is selected from the Item list in the Keyword View and when using IntelliSense.
QuickTest searches the function libraries in the order in which they are listed in the Resources tab. If QuickTest finds more than one function that matches the function name in a specific function library, it uses the last function it finds in that function library. If QuickTest finds two functions with the same name in two different function libraries, it uses the function from the function library that has the higher priority. To avoid confusion, it is recommended that you verify that within the resources associated with an application area, each function has a unique name.
Tip: If you choose not to register your function at this time,
you can manually register it later by adding a RegisterUserFunc statement after your function as
shown in the following example:
RegisterUserFunc "WebEdit", "MySet", "MySetFunc"
Note: A registered or global function can only be called from a component after it is added to a function library that is associated with the component's application area.
To register the function to a test object:
Note: If you clear the Register to a test object check box, the default test_object argument is automatically removed from the Arguments area (unless you renamed it).
For example, if you were to define the VerifyProperty operation as the default operation for the Link test object, the value True would be defined as the fourth argument of the RegisterUserFunc statement, and the syntax would appear as follows:
RegisterUserFunc "Link", "VerifyProperty", "VerifyProperty", True
After you specify the test object registration information, you specify additional arguments for the function. For more information, see Specifying Arguments for the Function.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/16792402/viewspace-567331/，如需转载，请注明出处，否则将追究法律责任。