我很难单击网络表中的特定行。我的代码查找适当的行,但是当我使用子项目方法时,它会抱怨找不到对象。这是我的代码:
Desc = "Record to click"
If Browser("B").Page("P").WebTable("W").exist(10) Then
totalRows = Browser("B").Page("P").WebTable("W").RowCount()
For RowNum = 1 To totalRows
If aDesc = Browser("B").Page("P").WebTable("W").GetCellData(RowNum,2) Then
Browser("B").Page("P").WebTable("W").ChildItem(RowNum,2,"WebElement",0).click
End If
Next
End If
我窥探了行中的值是Web元素,我尝试使用链接 - 不起作用。另外,我尝试 Child Item(aDesc,2,"WebElement",0)
- 也无法正常工作。我将0用于索引,因为行中只有一个元素 - 简单文本。在许多其他测试中,我一直在遇到此错误。在极少数情况下,这种方法在某些测试中起作用,但是大多数情况下,它在没有物体的情况下抱怨。
非常感谢您的帮助!
它也发生在我身上。当我进行研究时,我在一些旧的HP博客中发现了ChildItem方法与WebElement无法正常工作,但这是QTP 9.0,我使用的是12.02.,我无法弄清楚它的原因,并且结束了,并结束了。使用以下 -
Set oExcptnDetail = Description.Create
oExcptnDetail("micclass").value = "WebElement"
oExcptnDetail("html tag").value = "TD"
Set chobj=Browser("").Page("").WebTable("Code").ChildObjects(oExcptnDetail)
chobj(0).Click
在旁注上,为了检查webelement/link在特定行和列中存在,请使用以下内容。
Browser("B").Page("P").WebTable("W").ChildItemCount(2,2,"WebElement")
getcell数据将返回所需的行和列中的任何内容,无论其是什么(链接,webelement等),因此您假设循环是否会出错。
尝试以下:
browser(" b")。页面(" p")。webtable(" w")。object.Rows(ronnum-1).cells(colnum-1).click
我正在尝试单击表中的第一个链接,此代码单击项目
Set oDesc = Description.Create()
oDesc("html tag").Value = "A"
Set rc = Browser("B").Page("A").WebTable("html id:=gridTable").ChildObjects(oDesc)
rc(0).Click
'num = rc.Count() 'get the number of link in a page
'For i=0 to num-1
'ref = rc(0).GetROProperty("href") 'get the “href”propety of the i th link
'MsgBox ref
'Next
或
Browser("B").Page("A").WebTable("html id:=gridTable").ChildItem(2,8,"Link",0).click
成功单击我需要的链接