Skip to content

Win Select

Type: win-select  ·  Package: Desktop Activities v1.0.9

Selects an item in a ComboBox (drop-down list) or list of a desktop application, by its text or by its index (position).

It locates the control by its selector, brings its window to the front, opens it if it is a drop-down and looks for the item like this:

  1. If item is a whole number matching an existing position (starting at 0), it picks the item at that position.
  2. Otherwise, the item whose text equals item, case-insensitive.
  3. If none is equal, the first one that matches as a pattern: * and ? wildcards (Warehouse *) or a regular expression between slashes (/^Ware/).

Then it selects it (with the UIA selection pattern or, if the item doesn’t support it, with a click), closes the drop-down and checks that the control kept that item. If it did not, it tries again by clicking the item and, if it still does not match, the activity fails saying what was requested and what the control shows: it never continues with another value. The drop-down is also closed when the activity fails, so whatever the next activity does with the keyboard does not change the selection. Since version 1.0.9.

In Java (Swing) applications the selection is made through the Swing bridge: it opens the combo box, waits loadWait ms for its options to load and picks the one that matches item.

ParameterTypeDefaultDescription
selectorselector—The ComboBox or list.
itemstring | int—Text (supports wildcards or /regex/) or position (starting at 0) of the item to select.
ParameterTypeDefaultDescription
sessionZoanDesktopSession—Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window.
loadWaitint700Ms to wait after opening the combo box for its options to load (combo boxes that fetch them from a database when opened). In other applications it is the maximum wait for the options to appear after opening the combo box (since version 1.0.9).
timeoutnumber30000Maximum ms to wait for the control. Empty = the project’s UI timeout or, if not set, 30000.

This activity does not return a value.

MessageCause and fix
The item was not found among the … item(s) in the list.No item matches item. Check the exact text with Win List Items or use a wildcard. If the number is 0, the list hadn’t loaded its options yet.
'…' was requested, but the control shows '…' after selecting it.The application did not keep the item selected (it reverts it, validates it, or the combo box does not respond to the selection). Check whether the value is allowed at that point of the form; the message says what the control shows. Since version 1.0.9.
The item was not found among the … available item(s).The same, in a Java application’s combo box. If the options load slowly, raise loadWait.
The element is outside the visible area and could not be scrolled into view, …The combo box is hidden by its container’s scrolling. Add a Win Scroll before it.
The Java control could not be located unambiguously, so nothing was done. …In a Java app there are several identical combo boxes. Add an anchor or an idx to the selector.
Element not found with selector {…}.See common errors.
Win Select selector = (combo "City") item = "Bogotá" // by text
Win Select selector = (combo "Type") item = 0 // first item (by index)
Win Select selector = (combo "Warehouse") item = "Warehouse *" // the first one starting with "Warehouse "