The following sample searches an explorer control in an application, goes through the combo boxes, prints out the actual value of each combo box, and selects the text 'mytext' if the combo box has an item with this name.
Code: click into code to enlarge
control = Ranorex.FormFindChildClassName(form, "Internet Explorer_Server");
if control == None:
print 'ERROR: Cannot find explorer';
return -3;
element = Ranorex.ControlGetElement(control);
if element != None:
DumpElementTree(element, 0);
The function DumpElementTree prints out each combo box in the control.
Code: click into code to enlarge
def DumpElementTree(element,level):
level = level+1;
childCount = Ranorex.ElementGetChildCount(element);
for index in range(0,childCount):
child= Ranorex.ElementGetChild(element,index)
if child == None:
continue;
role = Ranorex.ElementGetRole(child);
if role == Ranorex.ROLE_SYSTEM_COMBOBOX:
print '----------------------'
print ' Name=',
print Ranorex.ElementGetName(child)
print ' Value=',
print Ranorex.ElementGetValue(child)
print ' Position=',
print str(Ranorex.ElementGetPosition(child))
Ranorex.MouseMoveToElement(child)
item = Ranorex.ElementFindChild(child, Ranorex.ROLE_SYSTEM_LISTITEM, 'myself');
if item != None:
Ranorex.ElementSelect(item,Ranorex.SELFLAG_TAKESELECTION);
DumpElementTree(child,level);
This sample works with the actual Ranorex version, you can do a little bit more in the next version (V0.9.4).
Please contact me if you cannot solve your problem with this version, i can send you a V0.9.4Beta1.
Jenö Herget
Ranorex Team |