能否循环读取验证点名为head1,head2的验证点
Sub mainDim Result As Integer
dim i as integer
for i = 1 to 2
'Initially Recorded: 2004-12-1320:07:03
'Script Name: test
Window SetContext, "Class=TMainForm", ""
PushButton Click, "ObjectIndex=3"
PopupMenuIDSelect 110
'这是本来的验证点
'Result = PushButtonVP (CompareImage, "ObjectIndex=3", "VP=head2;Wait=2,2")
Result = PushButtonVP (CompareImage, "ObjectIndex=3", "VP=head"&Str(i)&";Wait=2,2")
next i
end sub
我设的图像验证点的名分别为head1,head2 可以的!
个人觉得不过这种做法是不明智的
如果楼主的测试用例达到一定数量,那么楼主是否需要先执行完这n多的用例后得到你的验证点后然后执行自动化测试脚本么?
这个脚本在我执行的时候,是不能正确载入验证的图片的
在我们做的测试里需要做大量这样的验证麻烦能否告诉我这个脚本的问题在哪里?
或者怎样才能正确的循环读取验证点
谢谢~
能告诉怎么事先吗~~急
你用i 不是做循环参数的嘛,干嘛又给它加上str()?这样i 又变成了字符串了。直接VP=head"&i 不就行了?
按你说的执行是失败的
Sub MainDim Result As Integer
dim i as integer
dim y as integer
y = 2
i = 1
'Initially Recorded: 2004-12-1320:07:03
'Script Name: test
Window SetContext, "Class=TMainForm", ""
PushButton Click, "ObjectIndex=3"
PopupMenuIDSelect 110
'验证正常在线图片
Result = PushButtonVP (CompareImage, "ObjectIndex=3", "VP=head"&i&";Wait=2,2")
Window ResetTestContext, "", ""
PushButton Click, "ObjectIndex=3"
PopupMenuIDSelect 117
'验证离开状态图片
Result = PushButtonVP (CompareImage, "ObjectIndex=3", "VP=head"&y&";Wait=2,2")
Window ResetTestContext, "", ""
End Sub
如果验证点用上边这种格式,脚本编译不过,提示:
test.rec(22) Error: Variable 'i' type conflict
test.rec(33) Error: Variable 'y' type conflict
如果验证点改成:
Result = PushButtonVP (CompareImage, "ObjectIndex=3", "VP=head&i&;Wait=2,2")
Window ResetTestContext, "", ""
log是这么报的
Failure: Description Unable to load baseline image file
Script VP Name:head&i&
Script VP Type:Window Image
Actual Results File
testtagin.head&i&.actYPRB.img
Additional Information PushButtonVP
CompareImage,"ObjectIn dex=3","VP=head&i&;Wai
t=2,2"
Additional Output test.head&i&.actYPRB.img
robot现在没找到验证点文件,变量也没有得到值
我们之所以要这么做是因为要比对的图片较多,但都是同样大小规格一样,美中图片再不同状态下分别有三种图片状态,人工比对的话会很耗时间,所以才想用循环验证点的方法
斑竹告诉我可以实现,但怎样才算成功?或者sqabasic根本不支持,那我就放弃了,这块还是老老实实人工监测 你的脚本写错了,原因是你的脚本中
Result = PushButtonVP (CompareImage, "ObjectIndex=3", "VP=head"&Str(i)&";Wait=2,2")
这段代码 "VP=head"&Str(i)&" 连接以后是"head 1",中间有空格!所以脚本找不到加载的图片!
我写了个例子你可以看一下
Sub Main
Dim Result As Integer
'Initially Recorded: 2004-11-413:05:37
'Script Name: TestDll
dim i as integer
dim strSP as String
StartApplication "c:\WINNT\system32\calc.exe"
Window SetContext, "Caption=计算器", ""
for i = 1 to 2
strSP = "Window Image" +Trim(str(i))
STOP
PushButton Click, "ObjectIndex=" & str(9-i)
Result = WindowVP (CompareImage, "Caption=计算器", "VP=" + strSP)
next i
End Sub
脚本运行正常!
谢谢大版主,我已经实现了
用CStr()来代替Str()一样可行的.试试. 楼上说得对这是因为Str 函数的参数为一 Long型,其中可包含任何有效的数值表达式,当一数字转成字符串时,总会在前头保留一空位来表示正负。如果 参数为正,返回的字符串包含一前导空格暗示有一正号。
所以导致楼主出现的问题!
页:
[1]