Problems to find combobox control twice

Class library usage, coding and language questions.
Lotta
Posts: 2
Joined: Sun Jun 17, 2007 2:10 pm

Problems to find combobox control twice

Post by Lotta » Sun Jun 17, 2007 2:16 pm

Hi,

I am trying to automate a webpage with a lot of comboxes, tabs etc. First
I wanted to select a specific combobox and it works fine but then I want to select the same combobx again (after leaving focus of combobox) but I cannot get this to work. What is the error? It is the part after: ' #To be deleted further on (except last row)' that does not work.

global explorerParentControl
global explorerParentElement

explorerParentControl=selectCorrectEqViewControl(status, node, port, mib)
explorerParentElement=Ranorex.ControlGetElement(explorerParentControl);
explorerComboboxElement = Ranorex.ElementFindChild(explorerParentElement, Ranorex.ROLE_SYSTEM_COMBOBOX)
print 'Correct port combobox'
print explorerComboboxElement
noOfChildElements=Ranorex.ElementGetChildCount(explorerParentElement)
print "Number of element childs:"
print noOfChildElements
defaultPort=Ranorex.ElementGetValue(explorerComboboxElement)
Ranorex.MouseMoveToElement(explorerComboboxElement)
Ranorex.MouseClickElement(explorerComboboxElement)
portListElement = Ranorex.ElementFindChild(explorerComboboxElement, Ranorex.ROLE_SYSTEM_LIST)
if portListElement == None:
print 'ERROR: list of the combobox element not found'
return 1
print 'Correct port itemlist'
print portListElement
print 'CorrectPort first tiem'
print Ranorex.ElementGetChild(portListElement,0)
itemCount = Ranorex.ElementGetChildCount(portListElement);
for index in range(0,itemCount):
item = Ranorex.ElementGetChild(portListElement,index)
if item == None:
print 'Port not found'
break
print ' Item = ' + Ranorex.ElementGetName(item)
portName=Ranorex.ElementGetName(item)
if str(portName) == port:
print 'Port in list as expected'
setCorrectPort=Ranorex.ElementSetValue(explorerComboboxElement, port)
#Ranorex.ComboBoxSetSelectedText(Element5,port)
correctPortValue=Ranorex.ElementGetValue(explorerComboboxElement)
print correctPortValue
break
Ranorex.ControlSendKeys(explorerParentControl, "{DOWN}")
Ranorex.Sleep(4000);

#To be deleted further on (except last row)

Ranorex.ControlSetFocus(explorerParentControl)
Ranorex.Sleep(4000)
explorerComboboxElement2 = Ranorex.ElementFindChild(explorerParentElement, Ranorex.ROLE_SYSTEM_COMBOBOX)
print 'Correct port no 2 combobox'
print explorerComboboxElement2
noOfChildElements2=Ranorex.ElementGetChildCount(explorerParentElement)
print "Number of element childs:"
print noOfChildElements2
defaultPort2=Ranorex.ElementGetValue(explorerComboboxElement2)
Ranorex.MouseMoveToElement(explorerComboboxElement2)
Ranorex.MouseClickElement(explorerComboboxElement2)
portListElement2 = Ranorex.ElementFindChild(explorerComboboxElement2, Ranorex.ROLE_SYSTEM_LIST)
if portListElement2 == None:
print 'ERROR: list of the combobox element not found'
return 1
print 'Correct port no 2 itemlist'
print portListElement2
itemCount2 = Ranorex.ElementGetChildCount(portListElement2);
for index2 in range(0,itemCount2):
item2 = Ranorex.ElementGetChild(portListElement2,index2)
if item2 == None:
print 'Port not found'
break
print ' Item2 = ' + Ranorex.ElementGetName(item2)
portName=Ranorex.ElementGetName(item2)

admin
Site Admin
Site Admin
Posts: 350
Joined: Wed Jul 05, 2006 7:44 pm

Post by admin » Mon Jun 18, 2007 11:11 pm

I would suggest to use also the argument name in the ElementFindChild function or use the ElementFindChildPosition function if the combo boxes have no names but a fix position.

Jenö
Ranorex Team