You can also set the items of a combo box as follows:
Code: click into code to enlarge
element = Ranorex.ControlGetElement(comboBox)
# Use this line if the textbox of the combo is editable
#text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_TEXT)
# Use this line if the textbox of the combo is not editable (static)
text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_STATICTEXT)
Ranorex.ElementSetValue(text, 'Text')
itemCount = Ranorex.ElementFindChildren(element, Ranorex.ROLE_SYSTEM_LISTITEM)
for index in range(0,itemCount):
child= Ranorex.ElementGetChildFieldItem(index)
if child == None:
print 'Cannot read child' + str(index)
continue;
print 'child item =' + child[2]
Ranorex.ElementSetValue(text, child[2])
If you want to select only one item, use the following:
Code: click into code to enlarge
element = Ranorex.ControlGetElement(comboBox)
# Use this line if the textbox of the combo is editable
#text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_TEXT)
# Use this line if the textbox of the combo is not editable (static)
text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_STATICTEXT)
Ranorex.ElementSetValue(text, 'Text')
Hope it works for you.
Jenö
Ranorex Team |