Tricentis Tosca 16.0 Released on Feb-2023 ----- UFT has been upgraded from UFT 15.0.1 to UFT One 15.0.2, Beginning at November 2020.

Saturday 2 March 2019

WebTable methods in UFT/QTP

UFT/QTP helps to identify by providing Web table class. WebTable class provides various methods to work on web table. Webtable class contains various methods which allows to work on tabular structure.Tables inside web pages are implemented without any name or id attributes most of the times. This makes it difficult for Automation engineer to create robust scripts for identifying the Table correctly at run-time. Below are explained webtable methods with examples.

1. Exist 
2. RowCount
3. ColumnCount
4. GetCellData
5. GetRowWithCellText
6. ChildItem
7. ChildItemCount
8. 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

No comments:

Post a Comment

Note: only a member of this blog may post a comment.