Wrong selection in Combo Box : Automation API

Wrong selection in Combo Box

Class library usage, coding and language questions.

Wrong selection in Combo Box

Postby gkring » Wed Mar 26, 2008 4:54 pm

I'm trying to implement a simple text based selection of entries from a combo box. The combo box has 5 entries.
According to the program output, the right entry is being selected (see output), but the setting seems to have no effect (i.e. the previously set entry is still active).
According to the output on the screen a third entry (different from the previously set one and from the one to be set appears.
Here is the code, which has been basically copied from your Combobox example (self.Ranorex points to Ranorex):

Code: Select all
        print '---------------------------------------------------------------------'
        print ' Searching and testing a ComboBox'
        print '---------------------------------------------------------------------'
        comboBox = self.Ranorex.FormFindChildClassName(self.form.window,
                                                       'ComboBox', 1)
        if comboBox == 0:
            print 'ERROR: ComboBox not found'
            return
        print '  comboBox = ' + hex(comboBox)
        print '   moving the mouse to the ComboBox'
        self.Ranorex.ControlSetFocus(comboBox)
        self.Ranorex.ComboBoxHideDropDown(comboBox)
        self.Ranorex.MouseMoveToControl(comboBox)

        itemcount =  self.Ranorex.ComboBoxGetItemCount(comboBox)
        print '  itemcount=' + str(itemcount)
        for i in range(itemcount):
            text = self.Ranorex.ComboBoxGetItemText(comboBox, i)
            if text == email:
                if self.Ranorex.ComboBoxSetSelectedIndex(comboBox, i) == i:
                    print '    text=%s, index=%d set' % (text, i)
                else:
                    print 'could not set selected Index %d in combo box' % i
                break
            else:
                print '    text=%s' % text
        else:
            print 'Could not find entry %s in combo box' % text


Output:
---------------------------------------------------------------------
Searching and testing a ComboBox
---------------------------------------------------------------------
comboBox = 0x3801d2
moving the mouse to the ComboBox
itemcount=5
text=gerhard.kring@mincombj.com, index=0 set
clicked password Field
clicked Sign in Button
gkring
 
Posts: 5
Joined: Tue Sep 04, 2007 5:06 pm

Postby Support Team » Thu Mar 27, 2008 7:28 pm

Well, I just tried your code with a .NET 2.0 control and it worked perfectly well. Hmm, what kind of control is that ComboBox?

You can try to use the ComboBoxSetSelectedText method to select the right ComboBox item without looping through all the items.
Code: Select all
selectedIndex = Ranorex.ComboBoxSetSelectedText(comboBox, mail)


Or use the element approach to search for the right element and click that using the Mouse:
Code: Select all
comboBoxElement = Ranorex.ControlGetElement(comboBox)
itemElement = Ranorex.ElementFindChild(comboBoxElement, Ranorex.ROLE_SYSTEM_LISTITEM, mail)
Ranorex.MouseClickElement(itemElement)


Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby gkring » Fri Mar 28, 2008 12:52 pm

Thank you Alex for the proposals.
I have tried them all, but the result is the same as before.
The control is a specific control which is part of a software product from
a canadian company, which I got for testing.
I don't have the source code.
One thing which I have seen now is that Ranorex Spy also seems to have
some problems with the Control:
When I examine the Control I get:
Control:
Caption/text: gk@billtel.de
Class name: ComboBox #1
...
Element:
Role: StaticText (41)
Name: Renew
Class: ComboBox
Value: gk@billtel.de

Renew is a control with Class Static located in the
same window, but outside the combobox control...
gkring
 
Posts: 5
Joined: Tue Sep 04, 2007 5:06 pm

Postby Support Team » Mon Mar 31, 2008 9:30 am

This seems to be quite a strange control. Could you please compile a sample application containing that control and mail it to support[at]ranorex.com?

I would like to get a look at that control and maybe I can help you then.

Regards,
Alex
Ranorex Support Team
User avatar
Support Team
Site Admin
 
Posts: 4845
Joined: Fri Jul 07, 2006 5:30 pm
Location: Graz, Austria

Postby gkring » Tue Apr 01, 2008 4:03 pm

Today a new version of this software has been released.
I will test now with this version and come back to you if it still has problems.
gkring
 
Posts: 5
Joined: Tue Sep 04, 2007 5:06 pm


Return to Automation API

Who is online

Users browsing this forum: No registered users and 0 guests