Page 1 of 1

Simple ComboBox Select Item Issue

Posted: Tue Apr 06, 2010 10:58 pm
by costamesakid
There are a lot of posts regarding combobox issues so this is probably a duplicate but I cannot get this simple task to execute. All I am doing is reading values into variable from a CSV file. Then I want to open a combobox within a form and set the selected item to the variable. My code looks like this:

public static string Plat;

Ranorex.ComboBox Envronmentcb = repo.FormSystem_Manager___UNCLASS.EvironmentCombo;
Envronmentcb.Click("center");
ListItem listItem = Plat;
listItem.Click("center");


But when I run this code the script will fail after the combobox is opened and will never select the listitem.Ranorex returns the error "Ranorex.ElementNotFoundException: No element found for path 'bridge' within 10s."

'bridge' being the 1st value red in from the CSV file.

Any suggestions? Thanks

""

Re: Simple ComboBox Select Item Issue

Posted: Tue Apr 06, 2010 11:56 pm
by costamesakid
Looks like I needed the full path to my listitem. This code works:

Ranorex.ComboBox Envronmentcb = repo.FormSystem_Manager___UNCLASS.EvironmentCombo;
Envronmentcb.Click("center");
Ranorex.ListItem listItem = ".//listitem[@accessiblename='" + Plat + "']";
listItem.Click("center");


However I am having another related problem. The combo boxes on my form dont contain any distinguishing values in their paths, so I am trying to use indexes. The first combo box on my form is named 'Environment'. I modified the path to this object to "element[@class='QWidget']//combobox[1]", but when I select Highlight Element Ranorex highlights the 2nd combobox, in this case 'Platform'. Any suggestions? Thanks
ScreenHunter_01 Apr. 06 17.53.gif

Re: Simple ComboBox Select Item Issue

Posted: Wed Apr 07, 2010 3:43 pm
by Ciege
If you cannot select a combo box list item by name you can type the value you want to select into the combo box. Just after the combo box click action you can then start typing the value and it (should) allow you to enter a valid item.

Re: Simple ComboBox Select Item Issue

Posted: Wed Apr 07, 2010 4:21 pm
by costamesakid
Well, thats the problem I am having. I cannot get the focus to the correct combo box because my combo boxes dont have any accessible names. I tried "element[@class='QWidget']//combobox[1]" to set the focus to the 1st combo box on the page, but instead the 2nd combo box is getting the focus.

As far as I know Ranorex indexes start at 1 not 0 so '[1]' should put the focus on the 1st combo box but its not.

Re: Simple ComboBox Select Item Issue

Posted: Wed Apr 07, 2010 4:32 pm
by Ciege
Check and see how Spy recognizes the combo box for the index number. Automatic indexes of similar objects that cannot be uniquely identified can start with 0. So again, best way to determine this is to check out what Spy tells you.

If dev will not uniquely name your combo boxes you can do a little coding yourself to figure out which one you want to interact with. According to your screenshot each combo box has a label to its left. You can read the form for each label and check its Y coordinate relative to the form. From there you can do one of two things. 1) Search each combo box on the form and use the one with the same Y coordinate (means that the combo box and label are at the same height) or 2) do a little math to determine what order each label is in, then you can determine the order that each combo box is in and find each one based on that order.

Not ideal but a definite workaround if dev won't name the combo boxes for you.

Re: Simple ComboBox Select Item Issue

Posted: Wed Apr 07, 2010 5:10 pm
by Support Team
costamesakid wrote:As far as I know Ranorex indexes start at 1 not 0...
Just to make that sure: Indexes in RanoreXPath start with 1 (XPath standard); indexes in code are programming language dependent, but usually start with 0 (e.g. C# and VB have zero-based indexes).
costamesakid wrote:...so '[1]' should put the focus on the 1st combo box but its not.
Right, it should set focus to the first combo box found by Ranorex, but that is not necessarily the one at the top. That depends on the implementation of the control. Please, use the "Highlight Element" in Ranorex Spy to identify which element corresponds to each combobox.

Regards,
Alex
Ranorex Support Team

Re: Simple ComboBox Select Item Issue

Posted: Thu Apr 08, 2010 8:08 am
by costamesakid
I decided to go with a simple work around because for whatever reason Ranorex Spy could not identify the first combo box using indexes. I tried using [1] through [20] and the object was still not recognized.

We have just implement MSAA for our Qt apps so it could be an MSAA issue?

Anyway, i decided to click on another object, in this case the combo box field name, which is TEXT and has an accessible name. Then I recorded a TAB over to the actual combo box.

This work around will be fine so long as the tab order does not change. Thanks

Re: Simple ComboBox Select Item Issue

Posted: Thu Apr 08, 2010 8:22 am
by Support Team
costamesakid wrote:Ranorex Spy could not identify the first combo box using indexes
Can Ranorex Spy identify the first Combobox at all? Did you check with Spy by enabling the "Highlight Element" feature from the toolbar? Maybe the Comobox it is not recognized as a Combobox, but as another type of control (possibly an MSAA issue)...

Maybe you could post a Ranorex snapshot of that dialog!

Regards,
Alex
Ranorex Support Team