SeleniumHQ/selenium · error · TypeError
#{source.type} is not a valid input type
Error message
#{source.type} is not a valid input type What it means
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.
Source
Thrown at rb/lib/selenium/webdriver/common/interactions/scroll.rb:44
# @api private
#
class Scroll < Interaction
def initialize(source:, origin: :viewport, duration: 0.25, **opts)
super(source)
@type = :scroll
@duration = duration * 1000
@origin = origin
@x_offset = opts.delete(:x) || 0
@y_offset = opts.delete(:y) || 0
@delta_x = opts.delete(:delta_x) || 0
@delta_y = opts.delete(:delta_y) || 0
raise ArgumentError, "Invalid arguments: #{opts.keys}" unless opts.empty?
end
def assert_source(source)
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? WheelInput
end
def encode
{'type' => type.to_s,
'duration' => @duration.to_i,
'x' => @x_offset,
'y' => @y_offset,
'deltaX' => @delta_x,
'deltaY' => @delta_y,
'origin' => @origin.is_a?(Element) ? @origin : @origin.to_s}
end
end # PointerPress
end # Interactions
end # WebDriver
end # Selenium
View on GitHub (pinned to aa36b38e69)
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).
Example fix
# before scroll = Selenium::WebDriver::Interactions::Scroll.new(source: pointer, delta_y: 200) # => TypeError # after wheel = Selenium::WebDriver::Interactions::WheelInput.new wheel.create_scroll(delta_x: 0, delta_y: 200)
Defensive patterns
Strategy: type-guard
Type guard
def wheel_input?(src) src.is_a?(Selenium::WebDriver::Interactions::WheelInput) end Scroll.new(source: src, **opts) if wheel_input?(src)
Prevention
- Use the public scroll_by/scroll_to/scroll_from DSL, which obtains a WheelInput internally.
- Keep scroll actions wired only to WheelInput instances.
When it happens
Trigger: 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.
Common situations: Custom action-builder code that aliases the wrong device; refactors that reuse a pointer/key device variable for scrolling.
Related errors
- #{source.type} is not a valid input type
- #{source.type} is not a valid input type
- #{source.type} is not a valid input type
- #{source.type} is not a valid input type
- #{source.type} is not a valid input type
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/5a86092969cadefb.
Report an issue: GitHub.