0

I am automating a Java application using UFT 11.5. There is a grid in the application which can be identified as a Grid in UFT object spy. I have rows and columns in that Grid where dropdown and textboxes are placed and these objects can not be accessed using UFT (like we can access row and column combination in tables).

So I had to use virtual tables and click on the positions using x,y co-ordinates. This works. Now I want to access perticular row and column combination (like we can do for tables).

Is there any wawy to handle this in UFT? Please help

I am using this code. I click in the grid with x,y co-ordinates and once clicked i start typing value in the edit field considering cusrsor is at that position. Sample code as below -

Call clickGrid(WIN_VERTRAG_LE, 300, 55)

Public Sub clickGrid(strWinName, x, y)

JavaWindow(strWinName).JavaObject("Grid").Click x, y    

End Sub

Call enterGridTabKeys(WIN_VERTRAG_LE, 1, false, "2500")

Public Sub enterGridTabKeys(strWinName, nCount, clearContent, strInput)    

i = 0

Do until i = nCount
    JavaWindow(strWinName).JavaObject("Grid").PressKey micTab
    i = i + 1
Loop
If strInput <> "" Then
    With JavaWindow(strWinName).JavaObject("Grid")    
         If clearContent Then
            .PressKey micHome
            .PressKey micEnd, micShift    
            .PressKey micDel
        End If
    End With

    shortcut_senden strInput
End If  
End Sub


Public Function shortcut_senden(keys)


Set shortcut_senden= CreateObject("WScript.Shell")    
wait 1
shortcut_senden.sendkeys keys    
wait 1
Set shortcut_senden= nothing

End Function                
TheBlastOne
  • 4,291
  • 3
  • 38
  • 72
Gaurav345
  • 1
  • 2
  • Without code samples and possibly detailed descriptions of your GUI structure, it is impossible to give assistance. Straight answer to your question would be "Yes, there probably is a way" – TheBlastOne Nov 06 '14 at 07:44
  • I have updated code above. What information is needed for GUI structure. and what can be a probable way? – Gaurav345 Nov 06 '14 at 09:19
  • I´d go for `JavaWindow(strWinName).JavaObject("Grid").Object.X`. `X` can be any accessible field, property or method of the native Java grid instance. This allows you to query dimensions, for example, and implement access (or navigation through) the grid´s contents. Depending on what you want, you might implement X/Y addressing by intelligently navigating to the target cell in a relative way (starting from the previous target cell). – TheBlastOne Nov 06 '14 at 10:45
  • What do you mean by "object" in above code line. Is it the editable field inside grid? can you elaborate more - my first column in grid has dropdowns and I need to select values in the dropdowns in different rows. thanks for your help. – Gaurav345 Nov 06 '14 at 12:08
  • `TestObject.Object` returns the native Java object instance that the test object represents. Thus, if the test object is your grid, you can call it´s Java "API" from QTP scripts to explore or otherwise use the grid´s properties. – TheBlastOne Nov 06 '14 at 12:51
  • Can you give some example plz. I have not used this before. Thanks. – Gaurav345 Nov 07 '14 at 09:10
  • See http://stackoverflow.com/questions/8154277/qtp-how-do-we-capture-the-tool-tip-text-displayed-on-doing-mouseover-on-a-radi/8155180#8155180. Motti's answer suggests to call the native .title method of a test object. In a similar way, you could call any java method behind your Java test objects using the .Object field. – TheBlastOne Nov 28 '14 at 08:14

0 Answers0