Set WebTableInstance=Browser("CNF").Page("DetailsApplication").WebTable("VersionsList")
Call TestDeleteOneVersion("New Version (2)",1,0,"WebElement",2,"Link",0,0,WebTableInstance)
Sub TestDeleteOneVersion(ApplicationVersionName,NameObjectCol,NameObjectPosition,NameObjectMicClass,DeleteObjectCol,DeleteObjectMicClass,DeleteObjectPosition,DeleteConfirm,WebTableInstance)
RowNum=WebTableInstance.RowCount
For i=2 to RowNum
If WebTableInstance.ChildItem(i,NameObjectCol,NameObjectMicClass,NameObjectPosition).GetROProperty("innertext")=ApplicationVersionName Then
WebTableInstance.ChildItem(i,DeleteObjectCol,DeleteObjectMicClass,DeleteObjectPosition).Click
Exit For
End If
Next
If Browser("CNF").Dialog("DeleteApplicationVersionConfirm").Exist(2) Then
If DeleteConfirm=1 Then
Browser("CNF").Dialog("DeleteApplicationVersionConfirm").WinButton("OK").Click
Wait 1
If CheckExistentApplicationVersion(ApplicationVersionName,NameObjectCol,NameObjectPosition,NameObjectMicClass) Then
Reporter.ReportEvent micFail,"Failed in","Delete Application Version"&ApplicationVersionName
Else
Reporter.ReportEvent micPass,"Succeed in","Delete Application Version"&ApplicationVersionName
End If
ElseIf DeleteConfirm=0 Then
Browser("CNF").Dialog("DeleteApplicationVersionConfirm").WinButton("Cancel").Click
Wait 1
If CheckExistentApplicationVersion(ApplicationVersionName,NameObjectCol,NameObjectPosition,NameObjectMicClass) Then
Reporter.ReportEvent micPass,"Succeed in","Cancel deletion operation"&ApplicationVersionName
Else
Reporter.ReportEvent micFail,"Failed in","Cancel deletion operation"&ApplicationVersionName
End If
End If
Else
Reporter.ReportEvent micFail,"Failed in","Found Deletion confirm prompt box"
End If
End Sub
Set objTable = Browser("Browser").Page("51testing").WebTable("name:=wangyan")
intCol = 2
intRowCount = objTable.RowCount
For i = 3 To intRowCount
Reporter.ReportEvent micDone, "Row#: " & i & " - ", objTable.GetCellData(i, intCol)
If StrComp(objTable.GetCellData(i, intCol), micCellDoesNotExist, 1) <> 0 Then
Reporter.ReportEvent micDone, "Row#: " & i & " - ", objTable.ChildItem(i, intCol, "WebElement", 0).GetROProperty("innertext")
End If
Next
Set objTable = nothing
在循环语句中多次使用objTable对象,运行也没有出现问题。
感觉你遇到的问题不象是普遍的问题,可以试着把原先的代码再分解一下,看看能不能隔离出问题来。作者: dcyan 时间: 2007-4-26 12:40
ok,谢啦sdlkfj2, 我再看看作者: Sophie.zhang.cs 时间: 2007-4-26 18:29
请问GetCelldata这个方法可以直接用吗?作者: dcyan 时间: 2007-4-26 18:49
可以啊,Object.GetCellData(Row, Column),Object是一个WebTable对象
Quicktest professional help里面是这么说的
Sub GetCellData_Example()
'The following example uses the GetCellData method to display the
'contents of the cell located in cell 1, column 1 in a message box.
Set Text = Browser("Mercury Tours").Page("Search Results").WebTable("OutboundFlight").GetCellData(1, 1)
MsgBox "text contains" & Text
End Sub作者: dcyan 时间: 2007-4-26 18:55
hi,winfood,我试了几遍后发现,如果第一次循环WebTable中被删除了一行,第二次循环就不会报错,但是如果第一次循环WebTable中有行被删除了,第二次循环就会报错,提示不认识WebTable!
Set Set WebTableInstance=Browser("CNF").Page("DetailsApplication").WebTable("VersionsList")
WebTableInstance中莫非只能应用于不变的(行数)WebTable?作者: sealwt 时间: 2011-9-27 14:24
是不是删除后表格重新排行了,而循环的仍是旧的排行不是新的 可以尝试吧获取webtable也放入循环?仅个人想法尚未试验,期待最后解答