Micro Focus QTP (UFT) Forums
Unable to read numeric values from WebTable into Datatable - 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: Unable to read numeric values from WebTable into Datatable (/Thread-Unable-to-read-numeric-values-from-WebTable-into-Datatable)



Unable to read numeric values from WebTable into Datatable - Akhila - 10-25-2013

Hi There,

I had written a script to read values from webtable to Datatable then export to Excel.
Script is working well while reading values from weblist and stores it into Data table, but when it comes to Numaric values it just placing blank values in Data table.
What could be issue with the WebEdit fields with numerical values?
Script is as follows: Website I have used is http://www.mortgagecalculator.org/

Code:
Set oWT= Description.Create()
    oWT("html tag").value = "TABLE"
    oWT("INDEX").value = 2
    
    datatable.AddSheet "Mysheet"
    Set oTable = Browser("Mortgage Calculator").Page("Mortgage Calculator").webtable(oWT)
    RC = oTable.RowCount
    CC =oTable.ColumnCount(1)
    
    For i = 1 to CC
        ColHeader = oTable.GetCellData(1,i)
        Datatable.GetSheet("Mysheet").AddParameter ColHeader, " "
    Next
    
    For j= 2 to 8
            datatable.GetSheet("Mysheet").SetCurrentRow(j)
            Ccnt = otable.ColumnCount(j)
                For k=1 to Ccnt
                    celldata = otable.GetCellData( j, k)
                    datatable.GetSheet("Mysheet").GetParameter(k).Value = celldata
                    print celldata
                Next
    Next
datatable.Exportsheet  "C:\Users\u292693\Desktop\Book1.xls ","Mysheet"
    
    Set oTable = Nothing



RE: Unable to read numeric values from WebTable into Datatable - Parke - 11-14-2013

Akhila:

You are grabbing the $ or the % signs. Similarly, you are grabbing all the values in the drop down lists and not the values that have been selected.
I believe GetCellData only grabs the (static) text in a webtable. To grab the dynamic data, we need to use the childItem method.

If my understanding is wrong, please let me know.
Try running the following code to get the values.

Code:
Set oWT= Description.Create()
oWT("html tag").value = "TABLE"
oWT("INDEX").value = 2

Set oTable = Browser("Mortgage Calculator").Page("Mortgage Calculator").WebTable(oWT)
for j= 2 to 10
        If j = 6  Then
                print "found "&j&",1 value = " & oTable.ChildItem(j,1,"Link",0).GetROProperty("innertext")
        Else
                If oTable.ChildItemCount(j,2,"WebEdit") = 1 Then
                        print "found "&j&",2 value = " & oTable.ChildItem(j,2,"WebEdit",0).GetROProperty("value")
                ElseIf oTable.ChildItemCount(j,2,"WebList") = 1 Then
                        print "found "&j&",2 value = " & oTable.ChildItem(j,2,"WebList",0).GetROProperty("value")
                ElseIf oTable.ChildItemCount(j,2,"WebList") = 2 Then
                        print "found "&j&",2 value = " & oTable.ChildItem(j,2,"WebList",0).GetROProperty("value")
                        print "found "&j&",2 value = " & oTable.ChildItem(j,2,"WebList",1).GetROProperty("value")
                End If
        End If
Next
hth,

Parke


RE: Unable to read numeric values from WebTable into Datatable - Akhila - 11-26-2013

Thanks Parke for your valuable information. Its really helpful for me.
I was breaking my head on how to capture current value in the field than capturing all existing values from the list.

and I also have no idea that Getcelldata captures only static values not the dynamic one.

I try out based on your suggested scriptSmile

Thanks again !!