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:Teamcapybara Capybara Node Actions Selection

From Leeroopedia
Revision as of 11:53, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Teamcapybara_Capybara_Node_Actions_Selection.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Testing, Form_Interaction
Last Updated 2026-02-12 00:00 GMT

Overview

Concrete tools for interacting with select boxes, checkboxes, and radio buttons provided by Capybara::Node::Actions.

Description

Node::Actions#select finds a select box (or datalist input) using from: and selects an option by text. #check and #uncheck use _check_with_label (L364-384) which tries set(true/false) on the element; if the element is not interactable and automatic_label_click is enabled, it clicks the associated label instead. #choose follows the same pattern for radio buttons.

Usage

Call these methods with the control's label text, name, or id as the locator.

Code Reference

Source Location

  • Repository: capybara
  • File: lib/capybara/node/actions.rb
  • Lines: L201-211 (select), L150-152 (check), L178-180 (uncheck), L122-124 (choose)

Signature

def select(value = nil, from: nil, **options)
  # @param value [String] Option text to select
  # @param from [String] Label/name/id of the select box
  # @return [Capybara::Node::Element]
end

def check(locator = nil, **options)
  # @param locator [String] Label/name/id of the checkbox
  # @option options [String] option  Value attribute of checkbox
  # @option options [Boolean, Hash] allow_label_click  Click label if element non-visible
  # @return [Capybara::Node::Element]
end

def uncheck(locator = nil, **options)
  # Same params as check
  # @return [Capybara::Node::Element]
end

def choose(locator = nil, **options)
  # @param locator [String] Label/name/id of the radio button
  # @option options [String] option  Value attribute of radio button
  # @return [Capybara::Node::Element]
end

Import

require 'capybara'
# Available via Capybara::DSL or on any Node instance

I/O Contract

Inputs

Name Type Required Description
value (select) String No Option text to select
from (select) String No Label/name/id of the select box
locator String No Label/name/id of checkbox or radio
option String No Value attribute to match
allow_label_click Boolean/Hash No Click label if element hidden (default: automatic_label_click config)

Outputs

Name Type Description
element Capybara::Node::Element The interacted element or clicked label

Usage Examples

Select Dropdown

select 'March', from: 'Month'
select 'United States', from: 'Country'

Checkboxes

check 'I agree to terms'
uncheck 'Subscribe to newsletter'
check 'Red', allow_label_click: true

Radio Buttons

choose 'Male'
choose 'Credit Card', option: 'cc'

Related Pages

Implements Principle

Page Connections

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