Ranorex

how can I pick an element from a form without display

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



Joined: 26 Oct 2007
Posts: 49
Location: Texas

PostPosted: Fri Dec 07, 2007 6:35 pm    Post subject: how can I pick an element from a form without display
Given you have a combo box with 50 items, is it possible to select one of those items without scrolling down to it?

My problem is that in order to make this script reusable, I am entering the value in as a variable. That means I can not know the number of clicks for scrolling (or move the scroll bar) merely I just need to select the entry.

I have tried using ComboBoxFindString, ElementFindChild, and ComboBoxSetSelectedText and they have not worked.

---- edited
I realized this also is a need for all forms. In our main window we have many controls and fields and take up multiple 'pages'.

Can I pick the control without scrolling the page down to it? I notice that TreeViewSelectItem mentions scrolling an item into view and selecting it. Is there another equivalent method for forms in general (and controls like a combobox)?
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 344

PostPosted: Fri Dec 07, 2007 7:00 pm    Post subject:
Is the text field of the combo box editable?

Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
jasong



Joined: 26 Oct 2007
Posts: 49
Location: Texas

PostPosted: Mon Dec 10, 2007 5:49 pm    Post subject:
Some are. I have switched to using ControlSendKeys on those.

Others are but there are issues as to how you can select via key entry.

For example, one combobox is for US states. You can not enter 'CO' in that field as it will first select 'CA' (with the 'C' entry) and then switch to 'OH' with the 'O' entry.
You are forced to cycle through the list by number of repetative key entries. For example here, to select 'CO' you must enter 'C' twice.

This requires foreknowledge of the contents of the list which goes against reuse.

Is there a way to just select the combobox field then pick the entry from the list of available values?
Back to top
View user's profile Send private message
Support Team
Site Admin


Joined: 07 Jul 2006
Posts: 344

PostPosted: Tue Dec 11, 2007 1:09 am    Post subject:
You can also set the items of a combo box as follows:

Code: click into code to enlarge
element = Ranorex.ControlGetElement(comboBox)

# Use this line if the textbox of the combo is editable
#text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_TEXT)

# Use this line if the textbox of the combo is not editable (static)
text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_STATICTEXT)

Ranorex.ElementSetValue(text, 'Text')

itemCount = Ranorex.ElementFindChildren(element, Ranorex.ROLE_SYSTEM_LISTITEM)
for index in range(0,itemCount):
    child= Ranorex.ElementGetChildFieldItem(index)
    if child == None:
        print 'Cannot read child' + str(index)
        continue;
    print 'child item =' + child[2]
    Ranorex.ElementSetValue(text, child[2])


If you want to select only one item, use the following:

Code: click into code to enlarge
element = Ranorex.ControlGetElement(comboBox)

# Use this line if the textbox of the combo is editable
#text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_TEXT)

# Use this line if the textbox of the combo is not editable (static)
text = Ranorex.ElementFindChild(element, Ranorex.ROLE_SYSTEM_STATICTEXT)

Ranorex.ElementSetValue(text, 'Text')

Hope it works for you.

Jenö
Ranorex Team
Back to top
View user's profile Send private message Visit poster's website
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