标题: 请教SQAGetproperty运用 [打印本页] 作者: billrub 时间: 2004-10-12 11:20 标题: 请教SQAGetproperty运用 我如何可以运用SQAGetproperty取得HTML页面上的文本信息?
请哪位大侠以两句具体脚本帮忙指教一下。作者: 司空公子 时间: 2004-10-12 12:30
请参考《robot如何取页面输入域的文本内容》、《請問Robot 如何快速使用座標定位》、《如何让combox自动选取它的子项 》这几篇文章。作者: billrub 时间: 2004-10-12 13:50
result=sqagetproperty("type=htmldocument;htmltitle=loginerr.jsp","loginerr.jsp",ck)
if ck=1 then SQALogMessage sqaWarning, "error", "the pssword is error!"
我的目的是要抓取loginerr.jsp中的某一句文本,如此怎么调试也无济于事作者: 司空公子 时间: 2004-10-12 19:28
你先要搞清楚SQAGetProperty的语法各个参数的含义。
SQAGetProperty(recMethod$, property$, value)
这个property$ 是A case-sensitive property name. 也就是要一个大小写正确的属性名称。作者: billrub 时间: 2004-10-13 17:20
THKS
不过能麻烦你帮我看一下以下这段脚本否:
'$include "sqautil.sbh"
Sub Main
Dim result As Integer
dim dp as long
dim x as integer
dim nm as string
dim ps as string
dim ck as variant
dp=sqadatapoolopen("test")
'Initially Recorded: 2004-10-11 17:16:56
'Script Name: test1
for x=1 to 5
call sqadatapoolfetch(dp)
call sqadatapoolvalue(dp,1,nm)
call sqadatapoolvalue(dp,2,ps)
Window SetContext, "Caption=¾­¼Ã»§¿Ú×ۺϹÜÀí-¼à¹Üϵͳ - Microsoft Internet Explorer", ""
Browser SetFrame,"Type=HTMLFrame;HTMLId=mainFrame;\;Type=HTMLFrame;HTMLId=llFrame",""
Browser NewPage,"HTMLTitle=¾­¼Ã»§¿Ú×ۺϹÜÀí-¼à¹Üϵͳ",""
EditBox Click, "Type=EditBox;Name=loginName", "Coords=67,9"
InputKeys nm
EditBox Click, "Type=EditBox;Name=password", "Coords=28,10"
InputKeys ps
PushButton Click, "Type=PushButton;Name=Submit"
Browser SetFrame,"",""
result=sqagetproperty("caption=¾­¼Ã»§¿Ú×ۺϹÜÀí-¼à¹Üϵͳ - Microsoft Internet Explore;\;type=htmlframe;htmlid=mainframe;htmltitle=loginerr.jsp","title",ck)
if ck=1 then SQALogMessage sqaWarning, "error", "the pssword is error!"
msgbox ck
Toolbar Click, "ObjectIndex=7;\;ItemID=1020", "Coords=4,7"
Window SetContext, "Class=Shell_TrayWnd", ""
TabControl Click, "ObjectIndex=1;\;ItemIndex=4", ""
next
call sqadatapoolclose(dp)
End Sub
运行结果我并未能取得title值
注:乱码显示的地方是因为复制到论坛过程中造成的。
[ Last edited by billrub on 2004-10-13 at 17:26 ]作者: 司空公子 时间: 2004-10-13 18:04
全是乱码,看的头都晕了。
你的脚本是有框架结构的,所以稍微麻烦一点。
用Object Properties直接抓取。可以得到验证点的语法,如下:
Window SetTestContext, "Caption=Agile Advantage - Microsoft Internet Explorer", ""
Browser SetFrame,"Type=HTMLFrame;HTMLId=RightPane",""
Browser NewPage,"HTMLTitle=Select SubClass And Number",""
Result = ComboBoxVP (CompareProperties, "Type=ComboBox;Name=subClassId", "VP=Object Properties")
Window ResetTestContext, "", ""
这样就可以读出我需要的部分,然后进行整理。
比如:
Result = SQAGetProperty("Caption=Agile Advantage - Microsoft Internet Explorer;\;Type=HTMLFrame;HTMLId=RightPane;HTMLTitle=Select SubClass And Number;\;Type=ComboBox;Name=subClassId", "innerText", str1)
[ Last edited by billrub on 2004-10-13 at 21:20 ]作者: yang 时间: 2004-10-15 15:52
首先我先说我没有看明白是什么原因。:s
不过我给你一个建议不知道对你有没有帮助:在你加入SQAGetProperty取值语句之前录制一行转换设置当前窗口的语句,这种类似 以下形式:
Window SetContext, "Caption=about:blank - Microsoft Internet Explorer", ""
,然后试试看。供你参考