{"record":{"id":"9bd04121b8b1e3dd","repo":"SeleniumHQ/selenium","slug":"source-type-is-not-a-valid-input-type-9bd041","errorCode":null,"errorMessage":"#{source.type} is not a valid input type","messagePattern":"#(.+?) is not a valid input type","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb","lineNumber":39,"sourceCode":"  module WebDriver\n    module Interactions\n      #\n      # Actions related to pressing keys.\n      #\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":21,"sourceCodeEnd":55,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/typing_interaction.rb#L21-L55","documentation":"Raised as TypeError by TypingInteraction#assert_source when the source passed to TypingInteraction.new(source, type, key) is not a KeyInput. TypingInteraction encodes keyDown/keyUp and is only valid on a key input source. Reached via KeyInput#create_key_down / create_key_up (which pass self) or by direct construction.","triggerScenarios":"Constructing Interactions::TypingInteraction.new(pointer, :down, 'a') or with a WheelInput/NoneInput source. Reached through the public key_down/key_up DSL only if the key input lookup is bypassed.","commonSituations":"Custom action-builder code that wires a key press onto a pointer or wheel device; refactors that swap device variables.","solutions":["Use the public key DSL (driver.action.key_down('a').key_up('a').perform) which obtains a KeyInput internally.","If constructing TypingInteraction directly, ensure source.is_a?(Selenium::WebDriver::Interactions::KeyInput)."],"exampleFix":"# before\ntype_action = Selenium::WebDriver::Interactions::TypingInteraction.new(pointer, :down, 'a') # => TypeError\n\n# after\nkey = Selenium::WebDriver::Interactions::KeyInput.new\nkey.create_key_down('a')","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def key_input?(src)\n  src.is_a?(Selenium::WebDriver::Interactions::KeyInput)\nend\n\nTypingInteraction.new(src, type, key) if key_input?(src)","tryCatchPattern":null,"preventionTips":["Use driver.action.key_down/key_up rather than constructing TypingInteraction directly.","Keep key actions wired only to KeyInput instances."],"tags":["interactions","typing","key-input","assert-source","internal-api","ruby"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}