{"record":{"id":"7091830af036992b","repo":"SeleniumHQ/selenium","slug":"type-inspect-is-not-a-valid-key-subtype","errorCode":null,"errorMessage":"#{type.inspect} is not a valid key subtype","messagePattern":"#(.+?) is not a valid key subtype","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb","lineNumber":43,"sourceCode":"      #\n      # @api private\n      #\n\n      class TypingInteraction < Interaction\n        attr_reader :type\n\n        def initialize(source, type, key)\n          super(source)\n          @type = assert_type(type)\n          @key = Keys.encode_key(key)\n        end\n\n        def assert_source(source)\n          raise TypeError, \"#{source.type} is not a valid input type\" unless source.is_a? KeyInput\n        end\n\n        def assert_type(type)\n          raise TypeError, \"#{type.inspect} is not a valid key subtype\" unless KeyInput::SUBTYPES.key? type\n\n          KeyInput::SUBTYPES[type]\n        end\n\n        def encode\n          {type: @type, value: @key}\n        end\n      end # TypingInteraction\n    end # Interactions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":25,"sourceCodeEnd":55,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb#L25-L55","documentation":"Raised as TypeError by TypingInteraction#assert_type when the type passed to TypingInteraction.new(source, type, key) is not a key in KeyInput::SUBTYPES. SUBTYPES permits exactly :down (→ :keyDown), :up (→ :keyUp), and :pause (→ :pause). Any other Symbol or value is rejected at construction time.","triggerScenarios":"Constructing TypingInteraction.new(key_input, :press, 'a'), :type, 'keydown' (String), or :keystroke. Rarely user-facing because KeyInput#create_key_down / create_key_up hard-code :down/:up; only hit by direct TypingInteraction construction.","commonSituations":"Custom action-builder code or a port from another bindings language whose key-action names differ; passing a String instead of a Symbol.","solutions":["Use key_input.create_key_down(key) / create_key_up(key) so the type is set correctly.","If constructing TypingInteraction directly, pass exactly :down, :up, or :pause."],"exampleFix":"# before\nact = Selenium::WebDriver::Interactions::TypingInteraction.new(key_input, :press, 'a') # => TypeError\n\n# after\nact = Selenium::WebDriver::Interactions::TypingInteraction.new(key_input, :down, 'a')","handlingStrategy":"validation","validationCode":"SUBTYPES = Selenium::WebDriver::Interactions::KeyInput::SUBTYPES\ntype = type.to_sym if type.is_a?(String)\nraise \"unsupported key subtype: #{type}\" unless SUBTYPES.key?(type)","typeGuard":"def valid_key_subtype?(t)\n  Selenium::WebDriver::Interactions::KeyInput::SUBTYPES.key?(t.is_a?(Symbol) ? t : t.to_sym)\nend","tryCatchPattern":null,"preventionTips":["Use create_key_down/create_key_up rather than constructing TypingInteraction with a type.","If constructing directly, pass exactly :down, :up, or :pause."],"tags":["interactions","typing","key-input","argument-validation","internal-api","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}