Skip to content

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.

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):

byIn the Designervalue is…For <option value="CO">Colombia</option>
value (default)ValueThe option’s value attribute, exact."CO"
labelVisible textThe text the person sees, exact."Colombia"
indexPositionThe option’s position, starting at 0.0 if it is the first one
  • by is case-insensitive (Label works the same as label); empty means value.
  • If the list is multiple (<select multiple>), pass a list in value to choose several (all read with the same by); 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 timeout runs out.
ParameterTypeDefaultDescription
selectorselector—The <select> element.
valuestring | List—The option to choose: its value, its visible text or its position, according to by. For multiple selection, a list.
ParameterTypeDefaultDescription
pageZoanPageSession—The page session. Omit it inside a body; outside, pass the session variable (e.g. page = page).
bystring"value"How value identifies the option: value · label · index (see table). Since version 1.0.8.
timeoutnumber30000Maximum time in ms to wait. Empty, 0 or negative: the project settings value or, if none, 30000.

This activity does not return a value. To read the chosen option, use Get Value.

Page Select selector = (#pais) value = "CO" // <option value="CO">Colombia</option>
Page Select selector = (#pais) value = "Colombia" by = label // by the visible text
Page Select selector = (#cuota) value = 2 by = index // the third option
Page Select selector = (#moneda) value = cliente["moneda"] // value that comes from data
Page Select selector = (#temas) value = new List<string> { "rpa", "ai" } // multiple selection
Page Get Value selector = (#pais) → output: paisElegido
MessageCause 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> elementThe 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.
  • Click — for non-native drop-downs (built with div/JS).
  • Get Value — read the currently selected option.