点击WebTable中的行

 Method 1

'Get the tables DOM object

Set oDOMTable = Browser("").Page("").WebTable("").object

'To Click on (1,1) we can use:

Row = 1

Col = 1

oDOMTable.rows(Row - 1).Cells(Col - 1).Click



Method 2

We can also bind to the corresponding WebElement object of the target cell and then click it.

'Get the DOM table object

Set oDOMTable = Browser("").Page("").WebTable("").object
Row = 1

Col = 1

'Get the source index of the table

sIndex = oDOMTable.rows(Row - 1).Cells(Col - 1).sourceIndex

'Click on the WebElement using it's source index

Browser("").Page("").WebElement("source_Index:=" & sIndex).Click



Method 3

This method uses the Object Indentification hierarchy. Each row is a child object of the Table and each cell is a child of its table Row. So to click cell(1,1), we can use the following code:

'Get the WebTable test object

Set oDOMTable = Browser("").Page("").WebTable("").object

Row = 1

Col = 1



'Get the Row WebElement of the object

Set oRow = oWebTable.WebElement("html tag:=TR","index:=" & (Row - 1))



'Get the Cell WebElement of the object from the row element

Set oCell = oRow.WebElement("html tag:=TD","index:=" & (Col - 1))



'Click on the cell

oCell.Click



'Note: This approach may not work correctly if the Table has nested Tables inside it.



Method 4

This method can be used when we want to click on an object which is located inside a table cell:

'Get the WebTable test object

Set oDOMTable = Browser("").Page("").WebTable("").object

Row = 1

Col = 1

'Get the number of WebEdits present in specified Row,Col

iEditCount = oWebTable.ChildItemCount(Row, Col, "Link")



If iEditCount = 0 Then

MsgBox "No WebEdit present in 1,1"

Else

'Get the 1st WebEdit present in 1,1

Set oWebEdit = oWebTable.ChildItem(Row, Col, "Link", 0)



'Set the value

oWebEdit.Set "This is 1st WebEdit in 1,1"

End if

转载于:https://www.cnblogs.com/dushuai/articles/3433754.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值