将测试进行到底!
对global与localtable的理解
上一篇 /
下一篇 2007-04-13 18:19:11
/ 个人分类:QuickTest Pro
global 是全局的数据表,local table只是某个动作的本地数据表. 选择global,global中有多少行数据,qtp就会执行多少次. local action 只是全局中的一个部分,当然只是执行一次了.若想local table 中的数据全班执行,就只能手动加循环语句了.
如果你设置整个脚本的运行次数,自然和Global 有关,<BR>如果你设置某个action的运行次数,自然和它对应的localsheet有关,
global 是全局的!有几行数据程序就要回放几次!!不能重新设置!!
local 是局部的!有几行数据action 就要回放几次!!
设置action的重复次数的操作:反击action,选择action call property,即可进行选择.
下面有几种情况:
1.当global 有不止一行的数据,action call property->Run On all Rows
程序每次运行时,action中的每行都要执行
2.当global 有不止一行的数据,action call property->Run one iteration only
而且global的行数>action的行数,当action执行到最后一行后,不管此时global 的行数为几,下次回放时action都执行最后一行!
如果global的行数<action的行数,action就执行不到最后一行
3.action call property->Run from rows to rows
4.global的重复次数在test->run中设置。
代码:表的循环读取写数据
1.
dim countNum
countNum = DataTable.GetSheet("Global").GetRowCount
for i=0 to countNum-1
DataTable.SetCurrentRow(i)
Browser("Login Page").Page("Page_5").WebEdit("#form.name").set DataTable(("#form.name", dtLocalSheet)
...............
end
2.
Dim i,currentValue
i = 1
While i<= 3
Rem To find the value, you dan apply any of the following two fuctions :
Rem DataTable.Value(ParameterID [, SheetID]) or DataTable(ParameterID [, SheetID])
currentValue = DataTable.Value("LProductInfo","Action1")
Rem currentValue = DataTable("LProductInfo","Action1")
Browser("Login Page").Page("Page_3").Image("spacer").FireEvent "onmouseover"
Browser("Login Page").Page("Page_3").Image("spacer").Click
Browser("Login Page").Page("Page_4").WebButton("Create").Click
Browser("Login Page").Page("Page_5").WebEdit("#form.name").Set currentValue
Browser("Login Page").Page("Page_5").WebEdit("#form.productNo").Set currentValue
Browser("Login Page").Page("Page_5").WebEdit("#form.spec").Set currentValue
Browser("Login Page").Page("Page_5").WebEdit("#form.unit").Set currentValue
Browser("Login Page").Page("Page_5").WebButton("Save").Click
wait(2)
DataTable.GetSheet("Action1").SetNextRow
i = i+1
Wend
收藏
举报
TAG: