Micro Focus QTP (UFT) Forums
How to identify dynamic webtable as unique in QTP? - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: How to identify dynamic webtable as unique in QTP? (/Thread-How-to-identify-dynamic-webtable-as-unique-in-QTP)



How to identify dynamic webtable as unique in QTP? - sudheendramurthy - 10-01-2010

I have a scenario wherein I need to verify the webtable data. After
entering input query criteria, I get results and these results are in
the form of webtable. There are two webtables embedded in one. These
two tables are identified as two different objects once containing the
header column and other containing rows but the number of rows varies
from input to input. So if for one input I get 3 rows, then for some
other input I may get 20 rows and if i learn objects for both case they
are captured as two different webtables.
In short I need to identify this dynamic webtable as unique? How can I
use descriptive progrmming in this case, if applicable?


RE: How to identify dynamic webtable as unique in QTP? - KavitaPriyaCR - 10-06-2010

Two tables embedded in 1 is not clear for me, can u brief me that point?
Here is answer for how much i understood your question, lemme know if the answer is not clear.
You can get the total number of rows and columns for dynamic table as:
Say for example, if the table has the header as "header" which has the unknown number rows, then
Code:
'Get total number of columns first
cCount=Browser("title:=browser").Page("title:=page").WebTable("name:=header").getColumnCount
For i=0 To cCount-1
'Get total number of rows
rCount=Browser("title:=browser").Page("title:=page").WebTable("name:=header").getRowCount(i)
' now you can get the cell data as:
For j=0 To rCount-1
data=Browser("title:=browser").Page("title:=page").WebTable("name:=header").getCellData(i,j)
' Use the data
msgbox data



RE: How to identify dynamic webtable as unique in QTP? - Rajesh Ch - 01-04-2016

Hi Kavita,

According to my knowledge to find row count and column count for a webtable are RowCount and ColumnCount(rownum) respectively. If i am wrong correct me.


RE: How to identify dynamic webtable as unique in QTP? - atul4278 - 02-09-2016

(10-01-2010, 03:46 PM)sudheendramurthy Wrote: I have a scenario wherein I need to verify the webtable data. After
entering input query criteria, I get results and these results are in
the form of webtable. There are two webtables embedded in one. These
two tables are identified as two different objects once containing the
header column and other containing rows but the number of rows varies
from input to input. So if for one input I get 3 rows, then for some
other input I may get 20 rows and if i learn objects for both case they
are captured as two different webtables.
In short I need to identify this dynamic webtable as unique? How can I
use descriptive progrmming in this case, if applicable?

I do not understand the need for u to identify unique webTable for different input/output.
Do the Columns vary for each different input value?

In your case u can get the column count of WebTable1 and iterate to the required column. And get the column number.
Now use the same column number along with rows of WebTable2 to verify the required value.

Even if the number of rows differ for different input.....as long as your table structure remains the same you should be able to access table values dynamically....hence no need to uniquely identify columns every time

Let me know if got it.


RE: How to identify dynamic webtable as unique in QTP? - vinod123 - 02-23-2016

try this code

Code:
Browser("Point").Sync
' WebTable
Obj = Browser("Point").Page("VBScript Decisions").WebTable("Statement")
' Fetch RowCount
x = Obj.RowCount
print x

' Fetch ColumnCount
y = Obj.ColumnCount(1)
print y

' Print the Cell Data of the Table
For i = 1 To x Step 1
   For j = 1 To y Step 1
      z = Obj.GetCellData(i,j)
      print "Row ID : " & i & " Column ID : " & j & " Value : " & z
   Next
Next

'Fetch the Child Item count of Type Link in a particular Cell
z = Obj.ChildItemCount(2,1,"Link")
print z