Hi,
I'm automating a web application that has a number of comboboxes inside a frame. The comboboxes don't have individual names but I can identify them by their control ids or instances of class name (ThunderRT6ComboBox). I want to be able to grab all of the objects within the frame, go through each object in a loop and see if it's a combobox, and if it is, see if it contains the selection that I want to make. Can I do this and if so how? I've been looking at elements and all the samples but these are based on knowing the name of the object (which I don't have).
Thanks for any help you can give.
Mik
How can I find child objects if they have no name?
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.
The function DumpElementTree prints out each combo box in the control.
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
Code: Select all
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);
Code: Select all
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