Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QTP 9.5 - Select an element in a table
#4
Solved: 12 Years, 10 Months, 3 Weeks ago
Thank you very much QTPKing.

I'm using a JTable so I modify a little bit your script (I also changed the For loops into While loops).

Code:
'String which enable to identify the line
id = "090701224501893r"

'Column where we will search id
colIdLabel = "FIX.4.2"

'Column of the expected value
colExLabel = 8

If JavaWindow("Log Message").JavaTable("MessageTable").Exist Then
    nbCol = JavaWindow("Log Message").JavaTable("MessageTable").GetROProperty("cols")

    'We are trying to find 2 columns (one for the id and one for the expected value)
    nbFindCol = 0
    
    'Find the expected columns
    i = 0
    While nbFindCol<2 and  i<nbCol
        If  JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(0, i) = colIdLabel Then
            colIdNum = i
            nbFindCol = nbFindCol +1
        End If
        If  JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(0, i) = colExLabel Then
            colExNum = i
            nbFindCol = nbFindCol +1
        End If
        i = i+1
    Wend
    If nbFindCol <> 2 Then
        msgbox "Error : one of the column has not been found"
    Else
        nbRow = JavaWindow("Log Message").JavaTable("MessageTable").GetROProperty("rows")

        'Find the expected row
        i = 0
        found = false
        While found = false and i<nbRow
            If JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(i,colIdNum) = id Then
                rowExNum = i
                found = true
            End If
            i = i + 1
        Wend

        msgbox JavaWindow("Log Message").JavaTable("MessageTable").GetCellData(rowExNum,colExNum)
    End If
Else
    msgbox "The Java Table doesn't exists"
End If
Reply


Messages In This Thread
RE: QTP 9.5 - Select an element in a table - by SAKDOSS - 07-30-2009, 03:00 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Page element keep changing chong67 4 5,199 11-08-2016, 09:17 PM
Last Post: Paul Rammone
  Choosing element from array marvson 1 2,355 06-29-2016, 02:55 PM
Last Post: Ankesh
  Web Element: Not able to select value from drop down in Web Element. Rajeev 4 5,938 08-04-2015, 06:03 PM
Last Post: kbhargava505
  Multi Select in UFT/ QTP vanga 0 3,845 02-25-2015, 07:03 PM
Last Post: vanga
  How to capture tool tip within a web element frebuffi 3 4,256 11-10-2014, 10:06 AM
Last Post: learning_UFT

Forum Jump:


Users browsing this thread: 1 Guest(s)