QTP的那些事可重用action(call to existing action)的使用

参考了下QTP的帮助文档中的飞机订票系统的使用方式。

在被重用的action中设置action properties中的parameters属性,设置输出或者是返回的值。

parameter(“属性值”),即可,返回值也需要采用这种方式即可。

callAction “action名称[action所在的test的名称]”,action中输入参数1,action中输入参数2,…,action中输出参数,例如如下:

RunAction "销售日报表查询 [销售日报表]", oneIteration,"BJ-kk123-SH ","ON","ON","","",res
QTP的帮助文档对对于RunAction,说明是有三个参数,第一个参数是需要运行的action的路径,第二个是运行的迭代的次数(对于被运行的action如果参数是datatable的时候可能会用上),第三个参数就是被运行的action运行的输入参数值,parameter的介绍如下:

第一个参数ActionName参数

String

The name of the action.

Note: 在语句中必须要强制赋值给actionname不能使用变量进行设置. Do not use a variable. For example, write:
RunAction="Action1[ExternalTest]"
and not:
aName="Action1[ExternalTest]"
RunAction aName

第三个参数Parameters参数:

Variant

Optional.

The values and storage locations for the called action's input and output parameters. Input parameters are listed before output parameters.

For an input parameter, specify either a fixed value or the name of another defined parameter (可以是Data Table 参数, environment 参数, or 一个action中call action properties中的input parameter参数) from which the argument should take its value.

For an output parameter, specify either a variable in which you want to store the value or the name of a defined parameter (Data Table parameter, environment parameter, or an action output parameter of the calling action).

大致就是输入参数需要输入一个特定的值,而对于输出参数只需要指定一个变量赋值即可。在被调用的action中的输入参数或者是输出参数可以使datatable对象,可以使environment对象,可以使action属性中的输出参数属性。

原文地址:https://www.cnblogs.com/seniortestingdev/p/2416726.html