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 Text Field Selection

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

Overview

Text_Field_Selection is a technique for locating text input fields on a web page using smart selectors based on label text, placeholder, or attribute values.

Description

Text field selection provides a human-readable way to identify text input elements on a page. Rather than using fragile CSS selectors or XPath expressions, fields are found by their associated label text, placeholder text, or attribute-value pairs. This approach mirrors how human users identify form fields — by their visible labels.

The selector returns a wrapper object that provides value access and supports chaining with proximity selectors (near, above, below) for disambiguation when multiple fields share similar labels. The wrapper lazily resolves elements with retry logic for dynamic pages, ensuring that fields rendered asynchronously or behind loading states are located reliably.

This principle encourages test scripts that read like natural language descriptions of user behavior, reducing maintenance burden when the underlying DOM structure changes while labels remain stable.

Usage

Use Text_Field_Selection to target specific text input fields for write(), clear(), or assertion operations. It is commonly combined with the into() helper for write operations. This principle applies whenever a test needs to interact with:

  • Standard text inputs (<input type="text">)
  • Password fields (<input type="password">)
  • Email or search inputs
  • Textareas
  • Any input element that accepts text entry

Theoretical Basis

The smart selector resolution strategy follows a cascading search algorithm designed to maximize the likelihood of locating the correct element:

  1. Search by associated label — Look for a <label> element whose text matches the provided string, then resolve the linked input via the for/id attribute pairing.
  2. Search by placeholder attribute — If no label match is found, search for an input whose placeholder attribute matches the provided string.
  3. Search by attribute-value pairs — When an object is provided instead of a string, match inputs by the specified attributes (e.g., id, name, class).
  4. Apply proximity filtering — If relative selectors (such as near(), above(), below()) are provided, filter the candidate elements by their spatial relationship to the reference element.
  5. Return wrapper with lazy element resolution — The resulting TextBoxWrapper does not immediately query the DOM. Instead, it defers resolution until an action or assertion is performed, incorporating retry logic to handle dynamic page content.

This cascading approach ensures that the most semantically meaningful selector (a label) is tried first, falling back to less stable but still useful selectors only when necessary.

Related Pages

Implemented By

Page Connections

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