QTP中Action1表,如何读取第二行的值

来源:百度知道 编辑:UC知道 时间:2024/06/21 15:07:57
QTP中Action1表,如何读取第二行的值,我要函数实现 ,不要QTP中的设置,谢谢

QTP中DataTable的操作
由QTP自动生成的语句是这样的:
DataTable("Col", dtLocalSheet)
DataTable("Col", dtGlobalSheet)
其中,dtLocalSheet就是当前Action的DataTable,dtGlobalSheet就是Global的DataTable,Col是列名还有很多写法,比如
DataTable("Col", "Action2")
就是读取Action2的Col列。
你完全可以读取另一个Action的DataTable,而不需要跨Action传递变量,使用DataTable比变量更方便,因为结束后能在Result里看到运行时的值
你可以在一个Action里读取另外一个Action的列,但是要注意另外一个Action的当前行
比如你在Action1里读取Action2的某列,如果Action1运行到第二行,你读取的Action2还是第一行的数据,解决办法就是写上这句:
DataTable.GetSheet("Action2").SetCurrentRow(2)
你也可以用GetCurrentRow来获取Action1的行,然后再用SetCurrentRow来保持两个Action的当前行一致:
CurrRow = DataTable.GetSheet("Action1").GetCurrentRow
DataTable.GetSheet("Action2").SetCurrentRow(CurrRow)还有一种写法:
DataTable(1, "Action2")
这样就是读取Action2的第一列,不管第一列叫什么名字,都能读
这样就很方便,比如:
For i = 1 To 10
MsgBox DataTable(i, "Action2")
Next
这样就能循环读取Action2的1~10