Action间传值

上一篇 / 下一篇  2011-10-11 14:22:40 / 个人分类:QTP学习

场景一:适合较少参数的情况。

方法一(关键字视图):

1.   通过在对应的Action右键设置Action Properties->Parmaters->Input/Output Parmaters

2.   OutputAction中选取相应的控件,右键设置Insert Output value->选取所需属性值->modfiy->Test/action parameter->选取Parameter

3.   更改主调Actioncall Action时将参数带上,如RunAction "Enquary", oneIteration,dblTotal_price’oneIteration,输入,输出

4.   InputAction中通过如Parameter("dblTotal_price")进行使用。

方法二(专家视图):

1.   OutputActionParameter("TotalValue") = Browser("Mercury").Page("List Of Sales").

WebTable("Orders").GetCellData(NumTableRows,"Total")

2.   InputAction给返回值,Browser("Mercury").Page("List Of Sales").WebEdit("Sold to").

Set Parameter("SoldToCode")

 

场景二:适合较多参数的情况。

方法一:通过设置环境变量

在主调Action定义环境变量。如:Environment.Value("paytype_id")="Wire Transfer"

在需要使用的Action中通过Environment.Value属性引用。如:Browser("PageName ").Page("PageName ").WebList("paytype_id").Select Environment.Value("paytype_id")

Environment.Value的值在任何Action中都可重新赋值。与变量性质相同,以最后一次赋值为当前值,故可作为全局变量使用,用以各Action之间的数据传递。

方法二:通过globalsheet进行传递

方法三:通过创建并注册dictionary对象为QTP保留对象的方式,使用dictionary容器进行较多数量的参数传递。

注册方法:

Dim WshShell

Set WshShell =CreateObject("WScript.Shell")

WshShell.RegWrite "HKCU\Software\Mercury Interactive\QuickTest Professional\MicTest\ReservedObjects\GlobalDictionary\ProgID", "Scripting.Dictionary","REG_SZ"

Set WshShell = Nothing

注册后可以使用GlobalDictionary对象,在其它action也可调用。

方法四:通过加载外部文件的方式进行调用。


TAG: action Action QTP qtp ACTION 传值

 

评分:0

我来说两句

Open Toolbar