Sha256: c8ae8121dd0844f6bd63031086bab8db52e81d03e48838626d9a0cccc4ae80cc

Contents?: true

Size: 722 Bytes

Versions: 6

Compression:

Stored size: 722 Bytes

Contents

# frozen_string_literal: true

Capybara.add_selector(:radio_button, locator_type: [String, Symbol]) do
  label 'radio button'
  xpath do |locator, allow_self: nil, **options|
    xpath = XPath.axis(allow_self ? :"descendant-or-self" : :descendant, :input)[
      XPath.attr(:type) == 'radio'
    ]
    locate_field(xpath, locator, options)
  end

  filter_set(:_field, %i[checked unchecked disabled name])

  node_filter(:option) do |node, value|
    val = node.value
    (val == value.to_s).tap do |res|
      add_error("Expected option value to be #{value.inspect} but it was #{val.inspect}") unless res
    end
  end

  describe_node_filters do |option: nil, **|
    " with value #{option.inspect}" if option
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
capybara-3.21.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.20.2 lib/capybara/selector/definition/radio_button.rb
capybara-3.20.1 lib/capybara/selector/definition/radio_button.rb
capybara-3.20.0 lib/capybara/selector/definition/radio_button.rb
capybara-3.19.1 lib/capybara/selector/definition/radio_button.rb
capybara-3.19.0 lib/capybara/selector/definition/radio_button.rb