Select Option
Select Option
Section titled “Select Option”Type: page-select · Package: Browser v1.0.9
Chooses an option in an HTML drop-down list (<select>). The option is identified by its value (the value attribute of each <option>), by its visible text or by its position, according to by. It also supports multiple selection.
How it works
Section titled “How it works”It locates the <select> by its selector, waits until it’s visible and enabled, and chooses the option that matches value according to by. It then fires the input and change events, as if the person had chosen it.
by says how value is read (since version 1.0.8; before, it only matched the value attribute):
by | In the Designer | value is… | For <option value="CO">Colombia</option> |
|---|---|---|---|
value (default) | Value | The option’s value attribute, exact. | "CO" |
label | Visible text | The text the person sees, exact. | "Colombia" |
index | Position | The option’s position, starting at 0. | 0 if it is the first one |
byis case-insensitive (Labelworks the same aslabel); empty meansvalue.- If the list is multiple (
<select multiple>), pass a list invalueto choose several (all read with the sameby); those not in the list end up unselected. - If no option matches, the activity keeps waiting for it to appear (lists that are filled after the page loads) and fails when
timeoutruns out.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
selector | selector | — | The <select> element. |
value | string | List | — | The option to choose: its value, its visible text or its position, according to by. For multiple selection, a list. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
page | ZoanPageSession | — | The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page). |
by | string | "value" | How value identifies the option: value · label · index (see table). Since version 1.0.8. |
timeout | number | 30000 | Maximum time in ms to wait. Empty, 0 or negative: the project settings value or, if none, 30000. |
Output
Section titled “Output”This activity does not return a value. To read the chosen option, use Get Value.
Example
Section titled “Example”Page Select selector = (#pais) value = "CO" // <option value="CO">Colombia</option>Page Select selector = (#pais) value = "Colombia" by = label // by the visible textPage Select selector = (#cuota) value = 2 by = index // the third optionPage Select selector = (#moneda) value = cliente["moneda"] // value that comes from dataPage Select selector = (#temas) value = new List<string> { "rpa", "ai" } // multiple selectionPage Get Value selector = (#pais) → output: paisElegidoCommon errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'value' is required. | value is empty. |
Select failed: Timeout 30000ms exceeded. … | matches: 1 (…) | The <select> exists, but no option matches (most often: you passed the visible text without by = label, or the other way round), or the list is disabled. Check the options and by. |
Select failed: … | matches: 0 (…) | It didn’t find the <select>. Check the selector. |
Select failed: Error: Element is not a <select> element | The selector points to a drop-down built with <div>. Use Click to open it and choose. |
'…' is not a valid option index: use a whole number starting at 0. | With by = index, value is not a whole number greater than or equal to 0. |
'by' must be value, label or index (got '…'). | by has another value. Pick one of the three. |
'page' must be a ZoanPageSession. | page is empty outside a body. |