Win Select
Win Select
Section titled “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).
How it works
Section titled “How it works”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:
- If
itemis a whole number matching an existing position (starting at 0), it picks the item at that position. - Otherwise, the item whose text equals
item, case-insensitive. - 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.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The ComboBox or list. |
item | string | int | — | Text (supports wildcards or /regex/) or position (starting at 0) of the item to select. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanDesktopSession | — | Win Attach session. Inside a body it is taken automatically; without a session, the selector must include the window. |
loadWait | int | 700 | Ms 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). |
timeout | number | 30000 | Maximum ms to wait for the control. Empty = the project’s UI timeout or, if not set, 30000. |
Output
Section titled “Output”This activity does not return a value.
Common errors
Section titled “Common errors”| Message | Cause 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. |
Example
Section titled “Example”Win Select selector = (combo "City") item = "Bogotá" // by textWin Select selector = (combo "Type") item = 0 // first item (by index)Win Select selector = (combo "Warehouse") item = "Warehouse *" // the first one starting with "Warehouse "Related activities
Section titled “Related activities”- Win List Items — see which options the combo box has.
- Win Get Text — read the selected option.