海龙 2005-3-20 14:08
Robot GUI脚本错误控制
Benefite:
Window SetContext, "WindowTag=WEBBrowser", ""
Browser SetFrame,"Type=HTMLFrame;HTMLId=mainfr",""
HTMLLink Click, "Type=HTMLLink;HTMLText=" & product, ""
If sqafindobject("\;Type=Window;Caption=Microsoft Internet Explorer")=0 then
Result=SQAGetProperty("\;Type=Window;Caption=Microsoft Internet Explorer;\;Type=Label;ObjectIndex=1","Text",s)
If S="Please enter Method" then
Window SetContext, "Caption=Microsoft Internet Explorer", ""
PushButton Click, "ObjectIndex=1"
goto Benefite
End if
End if
GUI测试经常会出现被操作对象没有出现而导致回放失败,解决方法之一是插入延时时间,但是缺点是如果时间短,可能对象没有出现,还会导致错误。时间长,对象如果马上出现,由于延时的存在导致效率低下。
上边的例子是通过goto命令实现的循环,这种方法比加延时更高效一点。
仅供参考
charles 2005-4-5 16:33
这么做为何编译错误?
con: DelayFor (1000)
if sqafindobject("\;Type=Window;Caption=提示信息")=0 then
'Result = WindowVP (CompareProperties, "Caption=提示信息", "VP=Object Properties")
Result=SQAGetProperty("\;Type=Window;Caption=提示信息;\;Type=Label;ObjectIndex=1","Text",s)
if s="成功!" then
Window SetContext, "Caption=提示信息", ""
PushButton Click, "Text=确定"
goto con
end if
end if
编译错误信息
test.rec(26) Error: Unknown function: con
test.rec(45) Error: Label 'con' is missing
pcl2004_27 2005-5-4 15:22
这是因为你的脚本输入错误!
也就是cnn的位置必须和下边end sub必须对齐!
taoyi_cheng 2005-11-10 09:36
是应该对其还是放在第一列?
qqwc 2006-4-17 10:22
我是新手,
一直不知道怎么判断错误的提示窗口是不是会出现
看了斑竹的帖子,原来可以用sqafindobject
受益非浅,谢谢,太谢谢了
ax2004 2006-6-5 21:07
为什么要用 Go to ,用 While 不是更清楚一些吗...