Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:Getgauge Taiko Dropdown Selection

From Leeroopedia
Knowledge Sources
Domains Browser_Automation, Form_Interaction
Last Updated 2026-02-12 00:00 GMT

Overview

Technique for programmatically selecting options from HTML dropdown (select) elements in browser automation.

Description

Dropdown selection involves finding the <select> element by its label or attributes, then selecting one or more options by visible text, value attribute, index, or regex pattern. This is a common form interaction in web applications, as dropdown menus are used for everything from country selectors to category filters.

The selection process modifies the selected property of matching <option> elements within the <select>. For single-select dropdowns, selecting a new option automatically deselects the previously selected option. For multi-select dropdowns (those with the multiple attribute), multiple options can be selected simultaneously.

After modifying the selection, the implementation dispatches change and input events on the <select> element. This is essential because many web applications listen for these events to trigger cascading updates (e.g., selecting a country populates the state/province dropdown, or selecting a product category updates available filters).

Taiko supports several selection strategies to accommodate different testing needs:

  • By visible text -- Select options whose displayed text matches a string or regex. This is the most readable approach and mirrors how users interact with dropdowns.
  • By value attribute -- Select options by their value attribute, useful when the display text is ambiguous or localized.
  • By index -- Select options by their zero-based position in the list, useful for dynamic content where text and values are unpredictable.

Usage

Use dropdown selection when automating interactions with:

  • Form fields that use native HTML <select> elements
  • Filter controls that present options in dropdown format
  • Configuration panels where users choose from predefined options
  • Multi-select lists where multiple items need to be selected

Note: This principle applies to native HTML <select> elements. Custom dropdown components built with

and JavaScript typically require click-based interaction instead.

Theoretical Basis

The dropdown selection mechanism works through direct DOM manipulation combined with event dispatching:

  1. Locate the select element -- Find the <select> element using label text proximity, id/name attributes, or CSS selectors.
  2. Enumerate options -- Retrieve the list of <option> elements within the <select>.
  3. Match target options -- Compare each option against the selection criteria (text match, value match, index match, or regex match).
  4. Update selection state -- Set the selected property to true on matching options. For single-select dropdowns, deselect all other options first.
  5. Dispatch events -- Fire change and input events on the <select> element to notify the application of the selection change.

The return value is the visible text of the selected option(s), providing confirmation of what was actually selected.

Related Pages

Implemented By

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment