ITPub博客

首页 > Linux操作系统 > Linux操作系统 > Preparing the User-Defined Function

Preparing the User-Defined Function

原创 Linux操作系统 作者:ipqiaojj 时间:2009-03-14 15:49:06 0 删除 编辑

Preparing the User-Defined Function

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)

       dim y

       y = obj.GetROProperty("value")

       Reporter.ReportEvent micDone, "previous value", y

       MyFuncWithParam=obj.Set (x)

End Function

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/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2009-02-22

  • 博文量
    140
  • 访问量
    74096