我有一个网页分离成50+页,每页20条记录。需要对照sql数据库进行验证。
页面在表格底部表示为链接,如下所示:

现在,我的代码正确地单击了下一页(当前page+1),并且没有任何问题地验证了第1页到第10页。但当它单击最后一个链接(...)并转到第11页时,它跳过DB表中的20条记录,并开始验证webtable中的记录201和DB中的记录221。它有什么问题?
下面是我的代码:
set PagesLink=description.Create
PagesLink("micclass").Value = "Link"
PagesLink("html tag").Value = "A"
Do Until DBMaintenanceRS.EOF
Set PagesCollection = .WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").ChildObjects(PagesLink) 'Get links to pages. 10 links to pages are showed in bottom of table.
print PagesCollection.Count
For pc = 0 To PagesCollection.Count-1 'start pages loop
For rc = 2 to .WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").RowCount-1 'start table rows loop
For cc = 2 To .WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").ColumnCount(1) 'start table columns loop
wCell = .WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").GetCellData(rc, cc)
dbCell = DBMa
intenanceRS.Fields(cc-2)
If trim(dbCell) = trim(wCell) Then
Print "Pass"
Else
print "FAIL::: ID="&.WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").GetCellData(rc, 2)&"-Column='"&.WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").GetCellData(1, cc)&"'-Value="&wCell&"-=-VS DB: "&dbCell
End If
Next
cc=""
wcell=""
dbcell=""
DBMaintenanceRS.MoveNext
Next
rc=""
print pc&"-=-"& PagesCollection(pc).GetROProperty("innertext")
If pc=0 Then
If NOT(PagesCollection(pc).GetROPRoperty("innertext")="...") Then
PagesCollection(pc).Click
End If
Else
PagesCollection(pc).Click
End If
.Sync
wait 1
Set PagesCollection = .WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").ChildObjects(PagesLink)
Next
print "Next 10 pages"
pc=0
Set PagesCollection = .WbfGrid("html tag:=TABLE","html id:=cphBody_GridView1").ChildObjects(PagesLink)
print DBMaintenanceRS.Fields(0)
Loop发布于 2017-09-19 14:13:59
您的行数变量(rc)是对全局行数进行计数,但是web页面只包含当前的行数窗口(例如,21..40),所以您认为的第21行实际上是当前WbfGrid的第一行。
对于DB行和WbfGrid行,需要有单独的计数器。
https://stackoverflow.com/questions/46287154
复制相似问题