Skip to main content

Method Signature

await opensteer.select(options: SelectOptions): Promise<ActionResult>
Selects an option from a <select> dropdown element. You must specify one of: value, label, or index.

Parameters

options
SelectOptions
required
Configuration for the select action

Returns

ActionResult
Promise<ActionResult>

Examples

Select by Label

// Select option by visible text
await opensteer.select({
  description: 'Country dropdown',
  label: 'United States'
})

Select by Value

// Select option by value attribute
await opensteer.select({
  description: 'Language selector',
  value: 'en-US'
})

Select by Index

// Select the third option (zero-based index)
await opensteer.select({
  description: 'Priority dropdown',
  index: 2
})

Select with Selector

// Use CSS selector to identify dropdown
await opensteer.select({
  selector: '#country-select',
  label: 'Canada',
  description: 'Country dropdown'
})

Select with Element Counter

// Use element counter from snapshot
await opensteer.select({
  element: 18,
  description: 'State dropdown',
  value: 'CA'
})

Multiple Dropdowns in Form

// Fill out a form with multiple select elements
await opensteer.select({
  description: 'Country',
  label: 'United States'
})

await opensteer.select({
  description: 'State',
  label: 'California'
})

await opensteer.select({
  description: 'City',
  value: 'san-francisco'
})

Select First Option

// Select the first option in a dropdown
await opensteer.select({
  description: 'Sort by dropdown',
  index: 0
})

Important Notes

You must provide exactly one of value, label, or index. The action will fail if none are specified.
This method only works with native <select> elements. For custom dropdown components (like those built with <div> and <ul>), use click and input actions instead.
  • click - Click on custom dropdown elements
  • input - Type into searchable dropdowns
  • hover - Hover over dropdown elements