Ranorex

Wrong selection in Combo Box

 
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython
View previous topic :: View next topic  
Author Message
gkring



Joined: 04 Sep 2007
Posts: 5

PostPosted: Wed Mar 26, 2008 4:54 pm    Post subject: Wrong selection in Combo Box
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: click into code to enlarge

        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
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 256

PostPosted: Thu Mar 27, 2008 7:28 pm    Post subject:
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: click into code to enlarge
selectedIndex = Ranorex.ComboBoxSetSelectedText(comboBox, mail)


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


Regards,
Alex
Ranorex Support Team
Back to top
View user's profile Send private message Visit poster's website
gkring



Joined: 04 Sep 2007
Posts: 5

PostPosted: Fri Mar 28, 2008 12:52 pm    Post subject:
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...
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 256

PostPosted: Mon Mar 31, 2008 9:30 am    Post subject:
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
Back to top
View user's profile Send private message Visit poster's website
gkring



Joined: 04 Sep 2007
Posts: 5

PostPosted: Tue Apr 01, 2008 4:03 pm    Post subject:
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.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Ranorex Forum Index -> RanorexPython All times are GMT + 2 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum