teamcapybara/capybara · error · Capybara::UnselectNotAllowed

Cannot unselect option from single select box.

Error message

Cannot unselect option from single select box.

What it means

Error "Cannot unselect option from single select box." thrown in teamcapybara/capybara.

Source

Thrown at lib/capybara/selenium/node.rb:101

        set_color(value)
      when 'range'
        set_range(value)
      else
        set_text(value, **options)
      end
    when 'textarea'
      set_text(value, **options)
    else
      set_content_editable(value)
    end
  end

  def select_option
    click unless selected? || disabled?
  end

  def unselect_option
    raise Capybara::UnselectNotAllowed, 'Cannot unselect option from single select box.' unless select_node.multiple?

    click if selected?
  end

  def click(keys = [], **options)
    click_options = ClickOptions.new(keys, options)
    return native.click if click_options.empty?

    perform_with_options(click_options) do |action|
      target = click_options.coords? ? nil : native
      if click_options.delay.zero?
        action.click(target)
      else
        action.click_and_hold(target)
        action_pause(action, click_options.delay)
        action.release
      end
    end

View on GitHub (pinned to 15b5fdb76e)

When it happens

Trigger: Thrown at lib/capybara/selenium/node.rb:101 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of teamcapybara/capybara@15b5fdb76e (2026-08-21). Data as JSON: /api/errors/bc81f7e55baef379. Report an issue: GitHub.