QTP Winobject table
Question ID: 104966
0
0

I want to be able to work with a table object in my application, but it is being seen only as a WinObject (probably due to a 3rd party toolset being used). I’ve been using low-level, but is there anyway to teach QTP how to work with it as in row/column like other tables?

Marked as spam
Posted by (Questions: 227, Answers: 22)
Asked on April 16, 2013 7:32 pm
184 views
Answers (2)
0
Private answer

How to read text from a Specific Cell ???

Marked as spam
Posted by (Questions: 0, Answers: 1)
Answered on February 12, 2014 8:29 am
2
Private answer

I have two little functions you could use to get a really simple solution for navigating a table-like object and setting a value in a cell. You can use the code as a template to build similar solutions if you'd like. It's basically using key navigation wrapped in loops controlled by the arguments that are passed in. The WinObject used is from a MS Excel workbook, but can of course be modified to something more appropriate for your needs:

'This function uses keyboard navigation to work with a table object. In this function example, an Excel
'Spreadsheet is used, but the WinObject lines should be changed to match your application

Function NavTable (RowNum,ColumnNum)

'Initialize Windows Scripting Shell object for keyboard use
Set WshShell = CreateObject(''Wscript.Shell'')

'Activate Table
Window(''Book1'').WinObject(''Book1'').Click

'Send Ctrl+HOME to go to home cell in upper left corner
WshShell.SendKeys ''^{HOME}''

'Use the row and column values to navigate through table using loops and key navigation

'Loop to desired row

For i = 1 to RowNum-1
WshShell.SendKeys ''{DOWN}''
Next

'Loop to desired column

For i =1 to ColumnNum-1
WshShell.SendKeys ''{RIGHT}''
Next

Set WshShell = Nothing

End Function

'This function is slightly different. It uses keyboard navigation to select the row/column, but also allows a typed
'value in the cell.

Function EditTable (RowNum, ColumnNum, TypeValue)

'Initialize Windows Scripting Shell object for keyboard use
Set WshShell = CreateObject(''Wscript.Shell'')

'Activate Table
Window(''Book1'').WinObject(''Book1'').Click

'Send Ctrl+HOME to go to home cell in upper left corner
WshShell.SendKeys ''^{HOME}''

'Use the row and column values to navigate through table using loops and key navigation

'Loop to desired row

For i = 1 to RowNum-1
WshShell.SendKeys ''{DOWN}''
Next

'Loop to desired column

For i =1 to ColumnNum-1
WshShell.SendKeys ''{RIGHT}''
Next

Window(''Book1'').WinObject(''Book1'').Type TypeValue

Set WshShell = Nothing

End Function

'Examples of calling the custom functions:

NavTable 6,8

EditTable 9,3,''Test Value''

Marked as spam
Posted by (Questions: 2, Answers: 477)
Answered on April 16, 2013 7:34 pm
EyeOnTesting

Welcome back to "EyeOnTesting" brought to you by Orasi Software, Inc.

X
Scroll to Top