{"record":{"id":"0520f7b18dc34fdf","repo":"SeleniumHQ/selenium","slug":"source-type-is-not-a-valid-input-type-0520f7","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/pointer_press.rb","lineNumber":59,"sourceCode":"                   forward: 4}.freeze\n        DIRECTIONS = {down: :pointerDown, up: :pointerUp}.freeze\n\n        def initialize(source, direction, button, **opts)\n          super(source)\n          @direction = assert_direction(direction)\n          @button = assert_button(button)\n          @type = @direction\n          @opts = opts\n        end\n\n        def encode\n          process_opts.merge('type' => type.to_s, 'button' => @button)\n        end\n\n        private\n\n        def assert_source(source)\n          raise TypeError, \"#{source.type} is not a valid input type\" unless source.is_a? PointerInput\n        end\n\n        def assert_button(button)\n          case button\n          when Symbol\n            raise ArgumentError, \"#{button} is not a valid button!\" unless BUTTONS.key? button\n\n            BUTTONS[button]\n          when Integer\n            raise ArgumentError, 'Button number cannot be negative!' if button.negative?\n\n            button\n          else\n            raise TypeError, \"button must be a positive integer or one of #{BUTTONS.keys}, not #{button.class}\"\n          end\n        end\n\n        def assert_direction(direction)","sourceCodeStart":41,"sourceCodeEnd":77,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/pointer_press.rb#L41-L77","documentation":"Raised as TypeError by PointerPress#assert_source when the source passed to PointerPress.new(source, direction, button, **opts) is not a PointerInput. PointerPress encodes pointerDown/pointerUp and is only valid on a pointer source; it also mixes in PointerEventProperties.","triggerScenarios":"Constructing Interactions::PointerPress.new(source, :down, :left, ...) with a non-PointerInput source, e.g. a WheelInput or KeyInput. Reached via PointerInput#create_pointer_down / create_pointer_up (which pass self) or direct construction.","commonSituations":"Hand-built action sequences that wire a press onto a wheel device; refactors that alias the wrong device variable.","solutions":["Use pointer_input.create_pointer_down(button, **) / create_pointer_up(button, **) so the correct source is passed.","Confirm source.is_a?(Selenium::WebDriver::Interactions::PointerInput) before constructing PointerPress."],"exampleFix":"# before\npress = Selenium::WebDriver::Interactions::PointerPress.new(key_input, :down, :left) # => TypeError\n\n# after\npointer = Selenium::WebDriver::Interactions::PointerInput.new(:mouse)\npointer.create_pointer_down(:left)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def pointer_input?(src)\n  src.is_a?(Selenium::WebDriver::Interactions::PointerInput)\nend\n\nPointerPress.new(src, dir, btn, **opts) if pointer_input?(src)","tryCatchPattern":null,"preventionTips":["Use pointer_input.create_pointer_down / create_pointer_up so the device is the source.","Keep press actions wired only to PointerInput instances."],"tags":["interactions","pointer-press","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"}