While automating web based application every automation QA has to deal with various kind of validation on web tables.The Web table class in UFT provides various methods to work on a web table. In this blog post, I will show you various useful web table methods in UFT with examples.
Web Table Methods in UFT
ChildItem Method
Returns a test object from the cell by type and index. The first object has an index of 0.
Example
1 2 3 4 5 |
'Getting 2nd link object from 2nd row 3rd column of the cell. Set ObjChildItem = Browser("Browser").Page("Page").WebTable("TableObject").ChildItem(2,3,"Link",1) ObjChildItem.Click |
ChildObjects Method
Returns the collection of child objects contained within the object. Here we need to first create the description of the object of the class for which we need to get the child objects. The following example returns all the hyperlinks of a web table.
Example
1 2 3 4 5 6 7 8 9 |
'Creating object for Link Class Set objLink=Description.Create objLink("micclass").value="Link" 'Retrieving all childobject of class Link Set ChildObj = Browser("Browser").Page("Page").WebTable("TableObject").ChildObjects(objLink) ChildObj(0).Click 'Clicking the first link |
ChildItemCount Method
Returns the number of objects of a specific type in the specified cell. The following example returns the count of all hyperlinks that are inside the second row and third column of a web table. The first row and column in the table are numbered 1.
Example
1 2 3 4 |
'Getting count of all link object from 2nd row 3rd column of the cell. iChildItemCount = Browser("Browser").Page("Page").WebTable("TableObject").ChildItemCount(2,3,"Link") Msgbox iChildItemCount |
GetCellData Method
Returns the text contained in the specified cell. We have to provide a row and column index.
Row and column index starts from 1. The following example returns the value from the first row and third column of a web table.
Example
1 2 3 |
sCellValue=Browser("Browser").Page("Page").WebTable("TableObject").GetCellData(1,3)'Returns value from 1st row 3rd Column Msgbox sCellValue |
GetRowWithCellText Method
Returns the number of the first row found that contains a cell with the specified text. This method is very useful in getting the row number of a cell with the specified text. This method is quite useful to directly get the row number of the required text without iterating the entire table and reading each cell value if it’s a unique value in each row of the table.
Example
1 2 3 |
iRowNum=Browser("Browser").Page("Page").WebTable("TableObject").GetRowWithCellText("I Love India") Msgbox iRowNum |
ColumnCount Method
Returns the number of columns in the table.
Example
1 2 3 |
iColCount = Browser("Browser").Page("Page").WebTable("TableObject").ColumnCount Msgbox iColCount |
RowCount Method
Returns the number of rows in the table.
Example
1 2 3 |
iRowCount = Browser("Browser").Page("Page").WebTable("TableObject").RowCount Msgbox iRowCount |
DoubleClick Method
Clicks on the object twice. This method can use to double click a clickable cell of a table.
Example
1 |
Browser("Browser").Page("Page").WebElement("innertext:=abcd").DoubleClick |
Recommended Posts
- Action Input And Output Parameters In UFT
- How to Use Shell Scripting in UFT to SendKeys
- Settings.WebPackage Replaytype in UFT
- How To Use Dictionary Object in UFT With Examples
- Find a Matching Pattern in String Using Regular Expression in UFT
- How to Use Regular Expression in UFT to Identify an Object
- File System Object UFT | VBA
- All You Need to Know About Object Identification in UFT
- Read and Update XML File in UFT | VBA
- VBScript MySQL Database Connection in UFT
- VBScript Loops in UFT
- 20 VBA Date Functions in UFT You Must Know