Micro Focus QTP (UFT) Forums
Newbie: How do i count through a webtable to find an entry? - 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: Newbie: How do i count through a webtable to find an entry? (/Thread-Newbie-How-do-i-count-through-a-webtable-to-find-an-entry)



Newbie: How do i count through a webtable to find an entry? - jove1776 - 08-24-2010

I need to find an entry in a web table but I am new to QTP and not sure how to do this. I have done the following:


Code:
Dim test1
Dim RCount
Dim CCount
Dim  fail

fail = "FAIL"
RCount = 1
CCount = 0
For RCount = 1 to RCount =  16
    For CCount = 0 to 16
test1 = Browser("Test").Page("TEST PAGE").Frame("mainFrame").WebTable("OrderTable").getcelldata(Rcount,CCount)  
If test1 = " 10337893" Then
msgbox test1
End If
CCount = Ccount +1
If test1 <>   "10337893" Then
msgbox fail
RCount = RCount +1
End If
next
next

But I really not sure how to do this, I am complete newbie to vbscripting too.


RE: Newbie: How do i count through a webtable to find an entry? - sreekanth chilam - 08-24-2010

Hi,

Try with RowCount,ColumnCount methods of WebTable and loop thru the WebTable.

Note: Once your expected entry is found, quit out of the loop using "Exit For" statement.

Hope you could solve it on your own Smile


RE: Newbie: How do i count through a webtable to find an entry? - supputuri - 08-24-2010

Hi,

If you want to check the existance of the specific data in the webtable you can use the "GetRowWithCellText" method which will retrive the row number where the data is displayed.

Code:
For intSearchColumn= 1 to Browser().Page().Frame().WebTable().ColumnCount(1)
  IntRowNum = Browser().Page().Frame().WebTable().GetRowWithCellText("10337893",intSearchColumn)
  If IntRowNum > 1 Then
   msgbox "Data found in Column : " & intSearchColumn & " Row : " & IntRowNum
   Exit For
  End If
Next

Please let me know if you need any more information.


RE: Newbie: How do i count through a webtable to find an entry? - jove1776 - 08-25-2010

Thanks to the both of you. I managed to figure it out but doing a slightly different way.

I have another question about function libraries files to create my own library but will post another thread.

Thanks!


RE: Newbie: How do i count through a webtable to find an entry? - SRA - 08-27-2010

Hi -

I see the VBScript but not QTP. How does QTP use this code? Is it called from a QTP script? Is this code actually in QTP? Sorry but don't see how this code works with QTP.

Thanks


RE: Newbie: How do i count through a webtable to find an entry? - supputuri - 08-27-2010

HI SRA,

we have to place this code in QTP and then execute ..... :-)