Micro Focus QTP (UFT) Forums
WebTable..Row and Column Count - 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: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: WebTable..Row and Column Count (/Thread-WebTable-Row-and-Column-Count)

Pages: 1 2


WebTable..Row and Column Count - Brian T. - 07-20-2010

I have a web table that I'm unable to get the row count and column count.

Code:
Set Tcount = Browser("APRS : REQUESTS PENDING").Page("APRS : REQUESTS PENDING").WebTable("Global Six Aprs Testsix")

msgbox Tcount.RowCount
msgbox Tcount.ColumnCount(1)

msgbox Tcount.GetCellData(1,1)

The above code only returns 1 row, 1 column and the cell data that is returned is not even part of the webtable inner text.

I attached a zip file with the source code, OR and Object Spy screen shots.

Thanks


RE: WebTable..Row and Column Count - sasmitakumari - 07-20-2010

Try this:
Code:
Tcount.GetROProperty("rows") and Tcount.GetROProperty("cols")
for row and cols count.
And loop through the counts(rows and cols), to fetch the cell data and debug through to find the what is the row number and column number for the cell for which you know the expected data.
Is it clear to you?
Ex:
Code:
a = Tcount.GetROProperty("rows")
b = Tcount.GetROProperty("cols")
For i = 1 to a
For j = 1 to b
c = Tcount.GetCellData(i,j)
msgbox c 'here you should be able to see what each cell has data in that table.
Next j
Next i



RE: WebTable..Row and Column Count - sreekanth chilam - 07-20-2010

@sasmita: What does the below statements do in the code ?
Code:
Next j
               Next i



RE: WebTable..Row and Column Count - sasmitakumari - 07-20-2010

those are for loop ending statements. If you need more details , search for "FOR loop" in QTP help file or google "For Loop +VB Script"
Code:
For i = 1 to a
   For j = 1 to b
     c = Tcount.GetCellData(i,j)
     msgbox c 'here you should be able to see what each cell has data in that table.
    Next j
Next i



RE: WebTable..Row and Column Count - Saket - 07-20-2010

hey Sasmita,

I have never seen a For loop ending statements like this in QTP nor in VB Script. dont remember but can be used in some other languages not in vbs.
try running these statements you will get syntax error: "expected end of statement".


RE: WebTable..Row and Column Count - sasmitakumari - 07-20-2010

Sorry, it is
For...
Next
I FORGOT to COMMENT i and j in loop.

Thanks Saket for validating Smile . You will get something like "For...Next Statement" when you search for the key word "FOR" in QTP help.

The code would be like:

For i = 1 to a
For j = 1 to b
....
Next ' j
Next ' i


RE: WebTable..Row and Column Count - basanth27 - 07-20-2010

sash -

And now it should make sense to Wrap your code in code tags.

By the way, why did you put j & i and comment it ? Serves any purpose ?

Kill me for the curiosity..Smile .. I probably would have used msgbox to see the value if that was the intention.


RE: WebTable..Row and Column Count - sasmitakumari - 07-20-2010

I kept i and j in comment to highlight/distinguish which "Next" is for which loop as per coding standard. One serves as inner loop and other one is outer loop.
In my above code For i = ... is outer loop and For j = ... is inner loop. So the First "Next" is end of For j loop and 2nd "Next" is end of For i loop.
Hope this clarifies your question.

Code:
For i = 1 to a
    For j = 1 to b
    ....
Next ' j
Next ' i



RE: WebTable..Row and Column Count - basanth27 - 07-22-2010

Absolutely. Thanks for your time to clarify.


RE: WebTable..Row and Column Count - Brian T. - 07-22-2010

Thanks for the help, the code you provided is giving me the same results.

Code:
Dim Tcount
Set Tcount = Browser("").Page("").WebTable("Global Six Aprs Testsix")

a = Tcount.GetROProperty("rows")
b = Tcount.GetROProperty("cols")
For i = 1 to a
    For j = 1 to b
c = Tcount.GetCellData(i,j)
msgbox i
msgbox j
msgbox c 'here you should be able to see what each cell has data in that table.
Next ' j
Next ' i

The code returns the value of 1 row and 1 column.

And the CellData that is returned is for the WebTable "Requests Pending
For Approval" which if you look at the attached screen shots is the WebTable that the "Global Six Aprs Testsix" WebTable is part of.

The Run-Time Object Properties of the Web Table "Global Six Aprs Testsix" innertext value is <multi-line value>.

For some reason it seems that there is only 1 row and 1 column in both web tables.

I hope I did not confuse you even more, but I need to be able to locate specific data in the webtable and then click on the object.

I did accomplish this process with other web tables where I can get the row/column count but for some reason I can not get the row/column of either web tables.

Any other suggestions would be greatly appreciated!

Brian