{"record":{"id":"5a86092969cadefb","repo":"SeleniumHQ/selenium","slug":"source-type-is-not-a-valid-input-type-5a8609","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/scroll.rb","lineNumber":44,"sourceCode":"      # @api private\n      #\n\n      class Scroll < Interaction\n        def initialize(source:, origin: :viewport, duration: 0.25, **opts)\n          super(source)\n          @type = :scroll\n          @duration = duration * 1000\n          @origin = origin\n          @x_offset = opts.delete(:x) || 0\n          @y_offset = opts.delete(:y) || 0\n          @delta_x = opts.delete(:delta_x) || 0\n          @delta_y = opts.delete(:delta_y) || 0\n\n          raise ArgumentError, \"Invalid arguments: #{opts.keys}\" unless opts.empty?\n        end\n\n        def assert_source(source)\n          raise TypeError, \"#{source.type} is not a valid input type\" unless source.is_a? WheelInput\n        end\n\n        def encode\n          {'type' => type.to_s,\n           'duration' => @duration.to_i,\n           'x' => @x_offset,\n           'y' => @y_offset,\n           'deltaX' => @delta_x,\n           'deltaY' => @delta_y,\n           'origin' => @origin.is_a?(Element) ? @origin : @origin.to_s}\n        end\n      end # PointerPress\n    end # Interactions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":26,"sourceCodeEnd":60,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/scroll.rb#L26-L60","documentation":"Raised as TypeError by Scroll#assert_source when the source passed to Scroll.new(source:, ...) is not a WheelInput. Scroll encodes a W3C wheel scroll action and is only valid on a wheel input source. Reached via WheelInput#create_scroll (which passes self) or by direct construction.","triggerScenarios":"Constructing Interactions::Scroll.new(source: pointer, ...) or source: key_input with a non-wheel device. Reached through the public DSL only if the internal wheel_input lookup is bypassed by custom code.","commonSituations":"Custom action-builder code that aliases the wrong device; refactors that reuse a pointer/key device variable for scrolling.","solutions":["Use the public scroll DSL (driver.action.scroll_by / scroll_to / scroll_from) which obtains a WheelInput internally via wheel_input.","If constructing Scroll directly, ensure source.is_a?(Selenium::WebDriver::Interactions::WheelInput)."],"exampleFix":"# before\nscroll = Selenium::WebDriver::Interactions::Scroll.new(source: pointer, delta_y: 200) # => TypeError\n\n# after\nwheel = Selenium::WebDriver::Interactions::WheelInput.new\nwheel.create_scroll(delta_x: 0, delta_y: 200)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def wheel_input?(src)\n  src.is_a?(Selenium::WebDriver::Interactions::WheelInput)\nend\n\nScroll.new(source: src, **opts) if wheel_input?(src)","tryCatchPattern":null,"preventionTips":["Use the public scroll_by/scroll_to/scroll_from DSL, which obtains a WheelInput internally.","Keep scroll actions wired only to WheelInput instances."],"tags":["interactions","wheel-scroll","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"}