The webtable object is used to test the table objects on the web page.
The test on table objects mainly obtains data, such as the number of rows, number of columns, and content of cells in the table. Common Methods for webtable objects include columncount, rowcount, getcelldata, and childitem. The syntax of the four methods is as follows.
Columncount method:
Description
Returns the number of columns in the table.
Syntax
Object. Columncount (Row)
Parameters |
Description |
Object |
Test object of the webtable type. |
Row |
Required. Long value. The row number. The first row in the table is numbered 1. |
Return type
Long value.
Rowcount method:
Description
Returns the number of rows in the table.
Syntax
Object. Rowcount
Parameters |
Description |
Object |
Test object of the webtable type. |
Return type
Long value.
Getcelldata method:
Description
Returns the text contained in the specified cell.
Syntax
Object. Getcelldata (Vtrow,Vtcolumn)
Parameters |
Description |
Object |
Test object of the webtable type. |
Vtrow |
Required. Variant value. The row number of the row where the cell is located. The first row in the table is numbered 1. |
Vtcolumn |
Required. Variant value. The number of the column where the cell is located. The first column in the table is numbered 1. |
Return type
String value. Returns the data contained in the specified cell.
If the specified cell is invalid, this method returnsMiccelldoesnotexist
Childitem method:
Description
Return the test objects in cells by type and index.
Syntax
Object. Childitem (Row,Column,Micclass,Index)
Parameters |
Description |
Object |
Test object of the webtable type. |
Row |
Required. Long value. The row number of the row where the cell is located. The first row in the table is numbered 1. |
Column |
Required. Long value. The number of the column where the cell is located. The first column in the table is numbered 1. |
Micclass |
Required. string value. Object type. |
Index |
Required. Long value. CellMicclassType of object index. When multiple cells existMicclassType object, this index indicates the required elements. The index of the first object is 0. |
Return type
ObjectObject.
Instance 1:
Dim rowcount
Rowcount = browser ("Browser"). Page ("page"). webtable ("webtable"). rowcount
Msgbox rowcount
For I = 2 to rowcount
Cons_no = browser ("Browser "). page ("page "). frame ("frame "). webtable ("HTML Tag: = table", "index: = 2 "). getcelldata (4, 2)
Reporter. reportevent micdone, "User ID", "User ID:" & cons_no
Next
Example 2:
Set objtable = browser ("creationtime: = 0 "). page ("index: = 0 "). frame ("Name: = treemenuframe "). webtable ("HTML Tag: = table", "index: = 1 ")
Dim introw
Introw = browser ("creationtime: = 0 "). page ("index: = 0 "). frame ("Name: = treemenuframe "). webtable ("HTML Tag: = table", "index: = 1 "). getroproperty ("rows ")
Dim intcolumn
Intcolumn = browser ("creationtime: = 0 "). page ("index: = 0 "). frame ("Name: = treemenuframe "). webtable ("HTML Tag: = table", "index: = 1 "). getroproperty ("Cols ")
Set objlink = objtable. childitem (introw, intcolumn, "image", 32)
If not objlink. exist (0) then
Msgbox "system does not have the menu you want to find. Please check it! "
Else
Objlink. Click
End if