Micro Focus QTP (UFT) Forums
does WebTable Object provides a method to get column number - 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: does WebTable Object provides a method to get column number (/Thread-does-WebTable-Object-provides-a-method-to-get-column-number)



does WebTable Object provides a method to get column number - umer830 - 12-09-2009

I have a web table object in my application where i have to search for an element get its row and column number. Once i gett the row number
using
GetRowWithCellText Method "

Next I want to know about column number but i could not find any function to get column number because i want to use object.GetCellData (Row, Column)
method to get complete cell text and verify wheather it contains my required text or not.


RE: does WebTable Object provides a method to get column number - Saket - 12-09-2009

once you get the row using GetRowWithCellText, loop through all the columns of webtable and find the column in which your text is there


RE: does WebTable Object provides a method to get column number - umer830 - 12-09-2009

Thanks for quick answer.


RE: does WebTable Object provides a method to get column number - basanth27 - 12-09-2009

Umer,
My 2 cents would you be to ask not to use getrowwithcelltext as the only option. In a webtable if you have rows with data which are duplicate then you will get the data of the first one and not the second one.

IF i were you then i would do the below,

1. Get the Row Count.
2. Get the Column Count
3. Loop through the Rows & columns using the GetCelldata(r, c).
4. From the CellValue obtained match it against the value you need.
5. Report Pass
5. Exit the Loop at that point.
6. If not found Report Fail.

Go ahead and write the code based on the above logic and you will get what you need.


RE: does WebTable Object provides a method to get column number - vijaychourasiya0109@gmail.com - 07-06-2018

(12-09-2009, 11:04 AM)umer830 Wrote: I have a web table object in my application where i have to search for an element get its row and column number. Once i gett the row number
using
GetRowWithCellText Method "

Next I want to know about column number but i could not find any function to get column number because i want to use object.GetCellData (Row, Column)
method to get complete cell text and verify wheather it contains my required text or not.

You can get the Column name with column number from below code:
Call getColumnName("Employee Name")
Function getColumnName(ColValue)
    Col_Names=Browser("").Page("").WebTable("").GetROProperty("column names")
        arr=split(Col_Names,";")
        counter=0
        For Iterator = 0 To UBound(arr) Step 1
            Found=0
            If arr(Iterator)=ColValue Then
                Found=1
                Print "Found"
                'this is for column possition
                counter=counter+1
                Exit For
            Else
                counter=counter+1
            End If
        'Next
    Next
    print counter
    If Found=1 Then
        print "Column Possition:"&"="&counter
    Else
        print "Column does not exit"
        
    End If
    getColumnName=ColValue
    
End Function