Tuesday 10 September 2013

QTP/UFT : Working with WebTable

QTP provides different methods to perform operation on WebTable.  This blog discusses about few of them -
How to check if  a WebTable exist
    msgbox Browser(…).page(…).webtable(…).exist ‘returns true/false
 How to find number of rows in WebTable
msgbox Browser(“").Page("").WebTable(“").RowCount  ‘ returns count of row in a           WebTable

How to find number of columns in a web table
    msgbox Browser("").Page("").WebTable(“").ColumnCount(1) ‘return column count in a 1st   
    row of WebTable

How to read data from a Cell WebTable
    msgbox Browser("").Page("").WebTable(“").GetCellData(row,column)
  ‘Where row & column specifies row number & column number of a Cell
How to find object using  childObject on a WebTable
 Set oDesc=Description.Create
 oDesc("micclass").value= WebCheckBox
 set oChild=Browser("").Page("").WebTable(“").ChildObjects(oDesc)
 msgbox oChild.count

How read data from WebTable using ChildItemCount and childItem
     oChild=Browser("").Page("").WebTable(“).ChildItemCount(row,col,” WebCheckBox”)
    If oChild >0
    Childitem will return object oftype defined in arguments for childitem
    Set cItem = Browser("").Page("").WebTable(“").ChildItem(row,col, WebCheckBox,0)
    If (strobjType = "Link" or strobjType ="WebEdit") Then
       cItem.Click
    ElseIf(stobjType = "WebCheckBox") Then
       cItem.Set "ON"
    End If
 

No comments:

Post a Comment