| View previous topic :: View next topic |
| Author |
Message |
jasong
Joined: 26 Oct 2007 Posts: 49 Location: Texas
|
Posted: Tue Dec 04, 2007 7:23 pm Post subject: with ComboBox, how to open up list or just select an item |
|
Two related questions:
Given a combo box, how do you select an item from the dropdown list without expanding the list?
To avoid location changes, how can you open up the list of items?
Here is what the recorder generated:
Code: click into code to enlarge
control = Ranorex.ControlFindChildControlName(parent, "cboCtsClient")
if control == 0:
return 1
Ranorex.ControlSetFocus(control);
controlElement = Ranorex.ControlGetElement(control)
if controlElement == None:
return 1
element = Ranorex.ElementFindChildLocation(controlElement, 43, "Open", "", 296, 320)
if element == None:
return 1
However, the use of a location is very dangerous for reuse.
I tried the following in place of ElementFindChildLocation but it returned None.
Code: click into code to enlarge
element = Ranorex.ElementFindChild(controlElement, 43, "Open", "WindowsForms10.COMBOBOX.app2", Ranorex.MATCH_SUBSTRING)
Am I using the right approach? |
|
| Back to top |
|
 |
jasong
Joined: 26 Oct 2007 Posts: 49 Location: Texas
|
Posted: Tue Dec 04, 2007 7:28 pm Post subject: |
|
I am also having the same problem with selecting tabs.
Is there a way to avoid using the location? |
|
| Back to top |
|
 |
Support Team Site Admin
Joined: 07 Jul 2006 Posts: 256
|
Posted: Tue Dec 04, 2007 11:56 pm Post subject: |
|
| Quote: |
| Is there a way to avoid using the location? |
Yes, you can also use the ElementFindChild function with the same arguments but without positions.
Use the:
Code: click into code to enlarge
element = Ranorex.ElementFindChild(controlElement, 43, "Open", "");
instead of:
Code: click into code to enlarge
element = Ranorex.ElementFindChildLocation(controlElement, 43, "Open", "", 296, 320);
But if you have two controls with the same Role, Name and ClassName, then you will get the first one without positions.
Jenö
Ranorex Team |
|
| Back to top |
|
 |
jasong
Joined: 26 Oct 2007 Posts: 49 Location: Texas
|
Posted: Wed Dec 05, 2007 6:00 pm Post subject: |
|
Thank you, this is working great.
One thing I noticed with another tool was that it enumerated duplicates like you mentioned using an underscore.
so it would be control, control_2, control_3 |
|
| Back to top |
|
 |
Support Team Site Admin
Joined: 07 Jul 2006 Posts: 256
|
Posted: Wed Dec 05, 2007 7:02 pm Post subject: |
|
You can enumerate all elements with the same Role as follows:
Code: click into code to enlarge
itemCount = Ranorex.ElementFindChildren(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON)
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]
If you only want to read the third child, you can do the following:
Code: click into code to enlarge
itemCount = Ranorex.ElementFindChildren(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON)
child= Ranorex.ElementGetChildFieldItem(2) # third child
You can also read all elements with a specified Role and Name as follows:
Code: click into code to enlarge
itemCount = Ranorex.ElementFindChildren(element, Ranorex.ROLE_SYSTEM_CHECKBUTTON, 'ndNode', "", Ranorex.MATCH_SUBSTRING)
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]
Jenö
Ranorex Team |
|
| Back to top |
|
 |
|
|
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
|
|