|
Dim WinCaption as string
Dim ObjectRec as string
Dim Result As Integer
Dim sinnerHtml as String
Dim Rows as integer
Dim Cols as integer
Dim CellText(1 to 1000,1 to 50) as String
Dim i,p as integer
Dim HTMLRows As integer
Dim RowsText as string
Result = WindowVP (Exists, "Caption=" & WinCaption, "VP=Window Existence")
if Result = 0 then
LogMessage "窗体 " & WinCaption & " 没有发现!!!",MainLog,Failed_MESSAGE
exit Function
End if
Window SetContext, "Caption=" & WinCaption , ""
Result = SQAGetProperty(ObjectRec,"innerHTML",sinnerHtml)
If Result = sqaSuccess Then
HTMLRows=GetFieldCount(sinnerHTML,0,chr(10)) '获取表格行数, '如果数据超过32767字符,Robot会死机
if HTMLRows<=1 Then
LogMessage "表格没有发现任何数据!!!",MainLog,Failed_MESSAGE
exit Function
end if
'逐行读取
Rows=0
for i=1 to HTMLRows step 1
RowsText=GetField(sinnerHTML,i,chr(10))
IF (instr(RowsText,"<TR")=1) or (instr(RowsText,"<TR")=2) Then
Rows=Rows+1 '表格每行
Cols=0
End if
IF (instr(RowsText,"<TD")=1) Then '查询出表格Cell的数据
Cols=Cols+1
p=instr(RowsText,"<A")
if p>0 Then RowsText=mid(RowsText,p+2,len(RowsText)-p-1)
p=instr(RowsText,">")
if p>0 then RowsText=mid(RowsText,p+1,len(RowsText)-p)
p=instr(RowsText,"</A>")
if p>0 then RowsText=mid(RowsText,1,p-1)
p=instr(RowsText,"</TD>")
if p>0 then RowsText=mid(RowsText,1,p-1)
CellText(Rows,Cols)=RowsText
End if
Next i
End If |
|