| View previous topic :: View next topic |
| Author |
Message |
mollusk
Joined: 13 Dec 2006 Posts: 5
|
Posted: Thu Mar 22, 2007 6:38 am Post subject: Table with combo boxes |
|
Hi.
I'm trying to access combo boxes in a table. What I need to do is:
1. get the number of items in each combo box
2. list the items in each combo box
3. select each item in each combo box
I'm having trouble with this. All the Ranorex combobox functions require the handle to the combobox in question, but I can't figure out how to get that.
So far what I have is something like this which returns the combobox tuple:
Code: click into code to enlarge
import RanorexPython as r
...
table = r.ElementFindChild(formElement, r.ROLE_SYSTEM_TABLE)
row = r.ElementGetChild(table, 1) # get the first row after the table header
# This returns a tuple not a handle!
combo = r.ElementFindChild(row, r.ROLE_SYSTEM_COMBOBOX)
Any help much appreciated  |
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Thu Mar 22, 2007 9:20 pm Post subject: |
|
The first element of the tuple is the handle of the control.
Print out the tuple and check the handle with RanorexSpy.
Jenö
Ranorex Team |
|
| Back to top |
|
 |
mollusk
Joined: 13 Dec 2006 Posts: 5
|
Posted: Fri Mar 23, 2007 1:27 am Post subject: |
|
That's what I assumed it would be, but on inspection the handle is the formElement's. If I spy on the combo itself when it is selected it has a completely different handle.
Using the following code I always get the number zero no matter how many items are in the combo.
Code: click into code to enlarge
print r.ComboBoxGetItemCount(combo[0])
|
|
| Back to top |
|
 |
admin Site Admin
Joined: 05 Jul 2006 Posts: 351
|
Posted: Sat Mar 24, 2007 9:25 pm Post subject: |
|
The following code works with the Ranorex sample application VS2005Application.exe.
It searches the list element of the combo box and reads all list items, it should also work with your combo box.
Code: click into code to enlarge
print '--------------------------------------------------------------------'
print ' Searching the combobox'
print '--------------------------------------------------------------------- '
print ' searching the comboBox by control name'
comboBox=Ranorex.FormFindChildControlName(form,'comboBox1')
if comboBox == 0:
print 'ERROR: comboBox not found'
return 1
print ' moving the mouse to the control'
element=Ranorex.ControlGetElement(comboBox)
combo = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_COMBOBOX)
if combo == None:
print 'ERROR: combobox element not found'
return 1
Ranorex.MouseClickElement(combo)
comboList = Ranorex.ElementFindChild(combo, Ranorex.ROLE_SYSTEM_LIST)
if comboList == None:
print 'ERROR: list of the combobox element not found'
return 1
itemCount = Ranorex.ElementGetChildCount(comboList);
for index in range(0,itemCount):
item = Ranorex.ElementGetChild(comboList,index)
if item == None:
break
print ' Item = ' + Ranorex.ElementGetName(item)
Please see also the function DumpElementTree from the sample ElementTest.py
Jenö
Ranorex Team |
|
| Back to top |
|
 |
|