SQAFindObject不能正确找到对象。
录制了一脚本,在一个页面中点击一按钮,进入下一个页面。然后修改这个脚本,加入一判断:使用SQAFindObject查找该页面是否有对应按钮,有则点击,没有则结束。
但是,SQAFindObject总是返回1003。这是为什么?
代码如下:红色部分是我添加的判断
Sub Main
Dim Result As Integer
'Initially Recorded: 2006-4-617:13:25
'Script Name: test_temp
Window SetContext, "Class=Shell_TrayWnd", ""
Toolbar Click, "Text=运行应用程序;\;ItemID=1", "Coords=21,23"
StartBrowser "http://192.168.0.128:9080/kent", "WindowTag=WEBBrowser"
delayfor 1000
Window SetContext, "WindowTag=WEBBrowser", ""
InputKeys "liaq{ENTER}"
Browser SetFrame,"Type=HTMLFrame;HTMLId=mainFrame",""
Browser NewPage,"HTMLTitle=kent system",""
ComboBox Click, "Type=ComboBox;Name=ACTOR_ID", ""
ComboListBox Click, "Type=ComboListBox;Name=ACTOR_ID", "Text=lianqi"
delayfor 1000
Result=SQAFindObject("Type=PushButton;Name=Submit1")
if(Result=sqaObjectNotFound) then
SQALogMessage sqaFail,"does not find the object",""
else PushButton Click, "Type=PushButton;Name=Submit1"
end if
InputKeys "%{F4}"
End Sub
请各位帮忙看看! 等待斑竹看看 可以在 红色字体上面加一句
Window SetContext,“识别方法”
试试
从属frame的要加上frame
例如:正确——
Window SetContext,“”
Result=SQAFindObject(".\;Type=HTMLFrame;HTMLId=mainFrame;\;Type=PushButton;Name=Submit1")
错误——
Window SetContext,“”
Browser SetFrame,"Type=HTMLFrame;HTMLId=mainFrame",""
Result=SQAFindObject("Type=PushButton;Name=Submit1")
User action则不用 谢谢wind。按照你的指导,成功了。开心ing~~~~~。
把修改后的部分贴出来:
Window SetContext,"WindowTag=WEBBrowser",""
Result=SQAFindObject(".\;Type=HTMLFrame;HTMLId=mainFrame;\;Type=PushButton;Name=Submit1")
if Result=sqaObjectNotFound then
SQALogMessage sqaFail,"does not find the object",""
else
Window SetContext,"WindowTag=WEBBrowser",""
PushButton Click, ".\;Type=HTMLFrame;HTMLId=mainFrame;\;Type=PushButton;Name=Submit1"
end if
页:
[1]