Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
WebTable..Row and Column Count
#1
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#2
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#3
Solved: 10 Years, 8 Months, 2 Weeks ago
@sasmita: What does the below statements do in the code ?
Code:
Next j
               Next i
Reply
#4
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#5
Solved: 10 Years, 8 Months, 2 Weeks ago
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".

Reply
#6
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#7
Solved: 10 Years, 8 Months, 2 Weeks ago
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.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#8
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply
#9
Solved: 10 Years, 8 Months, 2 Weeks ago
Absolutely. Thanks for your time to clarify.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#10
Solved: 10 Years, 8 Months, 2 Weeks ago
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  DataGrid: double click on selected row robertosalemi 0 4,269 05-12-2016, 03:00 PM
Last Post: robertosalemi
  Row count is always shown as 1 Harry1999 0 1,957 04-14-2016, 11:11 PM
Last Post: Harry1999
  [UFT] Get column name from SfwObject felino 0 2,884 12-02-2015, 04:07 PM
Last Post: felino
  Keep row number imbizile 0 2,542 09-18-2014, 03:31 AM
Last Post: imbizile
  Retrieve row number based on value in DataTable marfa 6 29,941 07-31-2014, 08:36 PM
Last Post: dharshinishankari@gmail.com

Forum Jump:


Users browsing this thread: 1 Guest(s)