Implementation:Getgauge Taiko DropDown Select
| Knowledge Sources | |
|---|---|
| Domains | Browser_Automation, Form_Interaction |
| Last Updated | 2026-02-12 00:00 GMT |
Overview
Concrete tool for programmatically selecting options from HTML dropdown elements provided by the Taiko library.
Description
The dropDown() function creates a DropDownWrapper that provides methods for interacting with HTML <select> elements. The wrapper's select() method supports selection by visible text (string or regex), by value attribute, or by index. It also provides options() to list all available options, value() to get the current selection, and exists() to check element presence.
The dropdown element is located by label text proximity or attribute-value pairs. After selecting an option, the implementation dispatches change and input events on the <select> element to trigger application-level event handlers.
Usage
Use dropDown() whenever you need to interact with native HTML <select> elements: selecting countries, choosing categories, picking options from filter dropdowns, or testing that correct options are available and selectable.
Code Reference
Source Location
- Repository: Taiko
- File:
lib/taiko.js(L1902, dropDown API),lib/elementWrapper/dropDownWrapper.js(L39-82, wrapper),lib/elements/dropDown.js(L1-248, element)
Signature
dropDown(labelOrAttrValuePairs, _options, ...args) -> DropDownWrapper
Import
const { dropDown } = require('taiko');
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| labelOrAttrValuePairs | string / Object |
Yes | Label text associated with the dropdown, or an object of attribute-value pairs (e.g., {id: 'country'}) to identify the <select> element.
|
| _options | Object |
No | Configuration options for element search behavior. |
| args | RelativeSearchElement[] |
No | Proximity selectors to narrow element search. |
DropDownWrapper Methods
| Method | Signature | Description |
|---|---|---|
select |
{index: number[]}) -> Promise<string> | Selects option(s) by visible text, regex, or index. Returns the text of the selected option. |
options |
options() -> Promise<string[]> |
Returns an array of all available option texts in the dropdown. |
value |
value() -> Promise<string> |
Returns the currently selected option's value attribute. |
exists |
exists() -> Promise<boolean> |
Returns true if the dropdown element exists in the DOM.
|
Outputs
| Name | Type | Description |
|---|---|---|
| return | DropDownWrapper |
A wrapper object providing select(), options(), value(), and exists() methods for interacting with the dropdown.
|
Usage Examples
Select by Visible Text
// Select 'Car' from a dropdown labeled 'Vehicle:'
await dropDown('Vehicle:').select('Car');
Select by Index
// Select the first option (zero-based index)
await dropDown('Vehicle:').select({index: [0]});
Select by Regex
// Select any option matching the regex pattern
await dropDown('Vehicle:').select(/Car/);
List Available Options
// Get all options in the dropdown
const opts = await dropDown('Vehicle:').options();
console.log(opts); // ['Car', 'Truck', 'Motorcycle']
Get Current Value
// Get the value attribute of the currently selected option
const val = await dropDown('Vehicle:').value();
console.log(val); // 'car'
Select by Attribute
// Find dropdown by its id attribute
await dropDown({id: 'country-selector'}).select('United States');