Qtp tests webtable objects

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.