QTP--Actions间传参

上一篇 / 下一篇  2014-01-09 11:01:29 / 个人分类:QTP自动化测试相关

Actions之间传递参数的三种方法:

  1. DataTable
  2. Environment
  3. Action Parameters

=============================

分别以三个例子来说明这三种方法:

    DataTable

Action1:

Dim parameter
parameter="DataTable"
DataTable.Value(1,1)=parameter

Action2:

msgbox parameter   // 无法得到输出结果

msgbox DataTable.Value(1,1)    //输出结果为DataTable

    Environment

Action1:

Dim parameter
parameter="Environment"
Environment.Value("aaa")=parameter
msgbox Environment.Value("aaa")

Action2:

msgbox parameter     // 无法得到输出结果
msgbox Environment("aaa")    // 输出结果为Environment

    Action Parameter

    *必须要有对象库

Action1:

1.在Action1上点右键>>>Action Properties>>>Parameters
2.在OutPut parameter中添加一个参数名
3.在Keyword视图中,在需要传值的控件上点右键>>>Insert Output Value,在Type列中勾选需要传的值,点 Modify 按钮, Output Types中选择 action parameter,Parameter选择步骤2中设置的参数名

Action2:

1.在Action2上点右键>>>Action Properties>>>Parameters
2.在Input parameters中添加一个参数名pb
3.在Action2上点右键>>>Action Call Properties>>>Parameter Values
4.在Input parameters中找到步骤2添加的参数名,在Value列上点击 Configure the value 按钮,在Parameter中选择action parameter,在Output from previous action call(s) 中,Action选Action1,Parameter选择Action1中步骤2中设置的参数名

可以通过msgbox parameter("pb")输出传参的结果。


TAG:

 

评分:0

我来说两句

Open Toolbar