Saturday, 1 March 2014

Working with the web table using QTP

In this post, i will explain how to work with the webtables using QTP code.

' Make sure that the web table object added to the repository
'Create an object with web table hirearchy
Set otable=Browser(".*").Page("*").WebTable("NameOfTheTable")
'Get the web table rowcnt
rowcnt=otable.RowCount
'msgbox rowcnt
'Get the web table column count for each row
colcnt=otable.ColumnCount(1)
'msgbox colcnt
'loop for rows
For i=1 to rowcnt
'loop for columns
For j=0 to colcnt-1
'get the cell data of the table
val=otable.GetCellData(i,j)
' msgbox val
If val="requiredValue" Then
' click on the link object inside the table
Set testing=otable.ChildItem(i,j+1,"Link",0)
testing.Click
Exit for
End If
Next
If val="requiredValue" Then
Exit for
End If
Next



No comments:

Post a Comment

Search This Blog