Simple ComboBox Select Item Issue

Ask general questions here.
costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Simple ComboBox Select Item Issue

Post by costamesakid » Tue Apr 06, 2010 10:58 pm

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

""

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Simple ComboBox Select Item Issue

Post by costamesakid » Tue Apr 06, 2010 11:56 pm

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

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Simple ComboBox Select Item Issue

Post by Ciege » Wed Apr 07, 2010 3:43 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Simple ComboBox Select Item Issue

Post by costamesakid » Wed Apr 07, 2010 4:21 pm

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.

User avatar
Ciege
Posts: 1336
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Simple ComboBox Select Item Issue

Post by Ciege » Wed Apr 07, 2010 4:32 pm

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.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Simple ComboBox Select Item Issue

Post by Support Team » Wed Apr 07, 2010 5:10 pm

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

costamesakid
Posts: 94
Joined: Tue Jun 16, 2009 10:27 pm

Re: Simple ComboBox Select Item Issue

Post by costamesakid » Thu Apr 08, 2010 8:08 am

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

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

Re: Simple ComboBox Select Item Issue

Post by Support Team » Thu Apr 08, 2010 8:22 am

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