Iterating through all items in a Combobox using code module

Ranorex Studio, Spy, Recorder, and Driver.
Posts: 36
Joined: Mon Jan 16, 2017 3:24 pm

Iterating through all items in a Combobox using code module

Post by manalitatke » Fri Mar 10, 2017 9:11 pm


I am trying to iterate through items of a combo-box using for-each loop in the user code module.

In the recording, i created a key-sequence for combo-box, and converted it to user code.
In this function, i am trying to iterate through each and every item of a combo-box using for-each loop.

The problem is: It just picks up one item and does not loop through the combo-box.
I have attached a screenshot of my Combo-box item.

I found this thread : ... t3132.html

and tried to implement this logic:

Button btn = repo.App.ComboBox.FindSingle("./button");
List lst = "/list";
foreach (ListItem lst_item in lst.FindChildren<ListItem>())

as guided by the support team

I understand that the 'repo.App.Combox'path should be the navigating path to the combo-box item.
However, i am unable to understand the List lst and its path?

I tried inputing my combo-box items ranorex path, the program compiles, however only the first item of the combo-box is selected and then it throws me an error in the report file as: The element does not support the required capability 'list'.

Can someone please explain the importance of List path here, and how should i proceed with my Combo-box loop iteration in Ranorex code module?

I also tried implementing data-driven approach by passing the combo-box items via excel sheet, however not all items are selected in this approach( some items are skipped, and some are repeated) even though the test case executes for exactly the same number of iterations as the number of rows specified in excel sheet used for data driven approach.

Can someone please guide me through the for-each looping and iteration approach in a for-each loop as:
1. Opening the Combobox
2. Selecting one item
3. Closing the combo-box
4. Loop as many times as the number of items in a combo-box.

You do not have the required permissions to view the files attached to this post.

User avatar
Ranorex Guru
Ranorex Guru
Posts: 7470
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Iterating through all items in a Combobox using code module

Post by odklizec » Mon Mar 13, 2017 8:25 am


Unfortunately, the combo box in provided snapshot seems contains just one item. Is it right or are there more items available if you open that combobox? If there are more items, then you need to capture the snapshot using Ctrl+Left Win key shortcut (so called Instant Tracking feature). Otherwise, the combobox items will not be available in snapshot. Then you will have to use something as described here, to cycle through individual ComboBox items: ... html#c3574
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration