或者你直接读InnerText属性值,数据分行的。。作者: bb64844866 时间: 2008-9-11 10:03 标题: 感谢回复 请问楼上的意思是要让我解析取出的所有字符吗?html语言我到是还比较熟悉,但是具体到怎么把这一大串字符解析出来还是不清楚。需要借助外部开发工具吗?然后引.dll?感觉有些复杂了。。。请再具体讲下!:)作者: 有零花钱的狗 时间: 2008-9-13 10:06
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作者: 有零花钱的狗 时间: 2008-9-13 10:14
如果你使用的是RRAFS框架,那么只要调用1个函数就可以,例子如下:
Dim WinCaption as string
Dim ObjectRec as string
Dim TableCell() '表格数据
' WinCaption ="**** - Microsoft Internet Explorer"
'ObjectRec ="Type=HTMLFrame;HTMLId=content;\;Type=HTMLTable;HTMLId=dgItemList"
Window SetContext, "Caption=" & WinCaption , ""
Call DDGGetGUIObjectData(ObjectRec ,TableCell(),"Contents")作者: 有零花钱的狗 时间: 2008-9-13 10:24
Dim Result As Integer
Dim DataArray(1 To 100,1 To 200) As String
Dim LineContents As String
Dim i,j As Integer
Dim Dir1,File1, file2 As String
Dim ColumnCount As integer
Dim sColIndex As integer
Dim sObjectName As String
sObjectName="************************"
Window SetTestContext, "CurrentWindow", ""
SqaSuspendLogOutput
Result = HtmlTableVP (CompareData, sObjectName, "VP=HTMLTableData;Wait=2,2;ExpectedResult=FAIL")
SqaResumeLogOutput
Window ResetTestContext, "", ""
' Robot provide one function to get "Actual Data" file, this file is always with full path and file name. the file name always contains "act" substring. (you can also get "expected data", but it means nothing.)
' But I found a problem. the Path is correct, but I cannot find the filename. it is very intersting! So we need find correct file for actual data.
File1 = sqaVPGetActualFileName("HTMLTableData","grd")
' Because the filename is not correct, we need to get correct file name.
' This function is to get the DIR name from UNCname. Maybe, you don't use UNCName, you need to change the function. it is very simple.
dir1 = GetDIRFromUNC(File1 )
' The following find the acutal data file. Rebot support the pattern matching. it is lucky that there is only one file with the format "*act*.grd".
File2 = Dir1 + DIR(dir1+"*act*.grd")
' After get the file, we can open the file use "open", you can open it as txt file.
' In the "*.grd" each line means each row in Listview Data.
' And there is one "tap" signal between each column. so it is very easy to manipulate the actual data.
if len(dir(File2))=0 Then
SqaConsoleWrite "获取表格(" & sObjectName & ")数据失败!"
exit sub
end if
Open File2 For Input As #99
'$CStrings
' Here give you one example to get each column each row, and print the value into console log .
Do until Eof(99) = -1
Line input #99, LineContents
j=j+1
For i = 1 to ColumnCount
DataArray(j,i)=GetField(LineContents,i,"\t")
SqaConsoleWrite cstr(i) + "=" + GetField(LineContents,i,"\t")
Next
loop
'$NoCStrings
Close #99