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