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.

Implementation:Getgauge Taiko RadioButton Select

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

Overview

Concrete tool for selecting radio button options within a radio group provided by the Taiko library.

Description

The radioButton() function creates a RadioButtonWrapper that provides methods for interacting with HTML radio button elements. The select() method clicks the radio button to select it, which automatically deselects any other radio button in the same group (sharing the same name attribute). The deselect() method clicks a selected radio button to deselect it. The isSelected() method inspects the current selection state without modifying it.

Radio buttons are located by their associated label text or attribute-value pairs, following the same label-matching logic used across Taiko's form element APIs.

Usage

Use radioButton() when automating interactions with radio button groups: selecting gender, choosing payment methods, picking shipping options, or verifying that the correct radio button is pre-selected after form data loads.

Code Reference

Source Location

  • Repository: Taiko
  • File: lib/taiko.js (L1948-1952, radioButton API), lib/elementWrapper/radioButtonWrapper.js (L57-112, wrapper), lib/elements/radioButton.js (element)

Signature

radioButton(labelOrAttrValuePairs, _options, ...args) -> RadioButtonWrapper

Import

const { radioButton } = require('taiko');

I/O Contract

Inputs

Name Type Required Description
labelOrAttrValuePairs string / Object Yes Label text associated with the radio button, or an object of attribute-value pairs (e.g., {id: 'gender-male'}) to identify the radio button element.
_options Object No Configuration options for element search behavior.
args RelativeSearchElement[] No Proximity selectors to narrow element search.

RadioButtonWrapper Methods

Method Signature Description
select select() -> Promise<void> Selects the radio button by clicking it. Automatically deselects other radio buttons in the same group.
deselect deselect() -> Promise<void> Deselects the radio button by clicking it (applicable to custom radio implementations).
isSelected isSelected() -> Promise<boolean> Returns true if the radio button is currently selected, false otherwise.
exists exists() -> Promise<boolean> Returns true if the radio button element exists in the DOM.

Outputs

Name Type Description
return RadioButtonWrapper A wrapper object providing select(), deselect(), isSelected(), and exists() methods for interacting with the radio button.

Usage Examples

Select a Radio Button

// Select the 'Male' radio button
await radioButton('Male').select();

Check Selection State

// Verify which radio button is selected
const isSelected = await radioButton('Female').isSelected();
console.log(isSelected); // true or false

Select by Attribute

// Find radio button by its id attribute
await radioButton({id: 'payment-credit-card'}).select();

Deselect a Radio Button

// Deselect a radio button (for custom radio implementations)
await radioButton('Male').deselect();

Check Existence

// Verify the radio button element exists in the DOM
const exists = await radioButton('Male').exists();
console.log(exists); // true or false

Related Pages

Implements Principle

Requires Environment

Page Connections

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