Sunday, January 24, 2016

WebTable methods in QTP / UFT:

Here we will see following important WebTable methods with example.
Exist, RowCount, ColumnCount, GetCellData, GetRowWithCellText, ChildItem, ChildItemCount, ChildObject
--------------------------------------------------------------------
Exist
Description: Exist method is used to check whether the webtable is exist in the open application or not.
Syntax: Obj.Exist                                           
Return Type: A Boolean Value
Example: Dim Var
Var = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).Exist
Msgbox Var                      
----------------------------------------------------------------------
RowCount
Description: RowCount method is used to get the number of rows in the webtable.
Syntax: Obj.RowCount                                  
Return Type: Long
Example: Dim Row_Count
Row_Count = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).RowCount
Msgbox Row_Count
---------------------------------------------------------------------------------
ColumnCount
Description: ColumnCount method is used to get the number of Columns in the webtable.
Syntax: Obj.ColumnCount(Row)                   
Return Type: Long
Example: Dim Column_Count
Column_Count = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”). ColumnCount(Row)
Msgbox Column_Count       
----------------------------------------------------------------------------------------------
GetCellData
Description: GetCellData method is used to get the Text/Value contained in the specified cell in the webtable.
Syntax: Obj.GetCellData(Row,Column)       
Return Type: String
Example: Dim Var_Data
Var_Data = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”). GetCellData(Row_Num, Column_Num)
Msgbox Var_Data       
-----------------------------------------------------------------------------------------------------
GetRowWithCellText
Description: GetRowwithCellText method is used to get the number of first row found that contains a cell with the specified text in the webtable.
Syntax: Obj.GetRowwithCellText(Text, Column(Optional), StartFromRow (Optional))  
Return Type: Long
Example: Dim Row_Num
Row_Num = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”). GetRowWithCellText(Row_Num, Column_Num)
Msgbox Row_Num
------------------------------------------------------------------------------------------------------
ChildItem:
Description: ChildItem method is used when we want to get a test object from the cell in a webtable by type and index.
Syntax: Obj.ChildItem(Row, Column, MicClass, Index)         
Return Type: An Obeject
Example: Dim ObjObject
ObjObject = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).ChildItem(2,1,”WebCheckbox”, 1)
---------------------------------------------------------------------------------------------------
ChildItemCount:
Description: ChildItemCount method is used when we want to get the number of objects of a specified Type in the specified cell in webtable.
Syntax: Obj.ChildItemCount(Row, Column, MicClass)          
Return Type: A Long Value
Example: Dim VarCount
VarCount = Browser(“Name:=Browser”).Page(“Title:=Page”).WebTable(“Name:=WebTable”).ChildItemCount(2,1,”WebCheckbox”)
--------------------------------------------------------------------------------------------------
ChildObjects
Description: ChildIObjects method is used when we want to get the number of child objects of a specified Type in the webtable.
Syntax: Obj.ChildObject(“MicClass”)           
Return Type: A collection of Objects
Example: Set Obj = Description.Create
     Obj("micclass").value = "Link"
Set  ObjChild = Browser("Name:=Page").Page("Title:=Page").WebTable("Name:=WebTable").ChildObjects(Obj)
For i = 0  to  ObjChild.count-1
MsgBox Obj1(i).GetROProperty("Name")

Next

1 comment:

  1. In example of GetRowWithCellText ---> Syntax is completely wrong it will give you error

    ReplyDelete