When you run a statement containing a registered method, it sends the test object as the first argument. For this reason, your user-defined function must have at least one argument. Your user-defined function can have any number of arguments, or it can have only the test object argument. Make sure that if the function overrides an existing method, it has the exact syntax of the method it is replacing. This means that its first argument is the test object and the rest of the arguments match all the original method arguments.
Tip: You can use the parent test
object property to retrieve the parent of the object represented by the first
argument in your function. For example:
ParentObj = obj.GetROProperty("parent")
When writing your function, you can use standard VBScript. statements as well as any QuickTest reserved objects, methods, functions, and any method associated with the test object specified in the first argument of the function.
For example, suppose you want to report the current value of an edit box to the Test Results before you set a new value for it. You can override the standard QuickTest Set method with a function that retrieves the current value of an edit box, reports that value to the Test Results, and then sets the new value of the edit box.
The function would look something like this:
Function MyFuncWithParam (obj, x)
y = obj.GetROProperty("value")
Reporter.ReportEvent micDone, "previous value", y
Note: This function defines a return value, so that each time it is used by the component, the function returns the Set method argument value.
来自 “ ITPUB博客 ” ，链接：http://blog.itpub.net/16792402/viewspace-567334/，如需转载，请注明出处，否则将追究法律责任。