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 Pause#assert_source when the source passed into Pause.new(source, duration) is not an InputDevice (source.is_a? InputDevice is false). Pause is @api private; Pause is the most permissive interaction — it accepts any InputDevice (pointer, key, wheel, none).
Source
Thrown at rb/lib/selenium/webdriver/common/interactions/pause.rb:38
module Selenium
module WebDriver
module Interactions
#
# Action to create a waiting period between actions
# Also used for synchronizing actions across devices
#
# @api private
#
class Pause < Interaction
def initialize(source, duration = nil)
super(source)
@duration = duration
@type = :pause
end
def assert_source(source)
raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? InputDevice
end
def encode
output = {type: type}
output[:duration] = (@duration * 1000).to_i if @duration
output
end
end # Pause
end # Interactions
end # WebDriver
end # Selenium
View on GitHub (pinned to aa36b38e69)
Solutions
- Pass a real InputDevice instance: device.create_pause(duration) rather than hand-constructing Pause with an arbitrary source.
- Verify the device inherits Selenium::WebDriver::Interactions::InputDevice before constructing Pause.
Example fix
# before pause = Selenium::WebDriver::Interactions::Pause.new(:pointer, 0.5) # => TypeError # after pointer = Selenium::WebDriver::Interactions::PointerInput.new(:mouse) pause = Selenium::WebDriver::Interactions::Pause.new(pointer, 0.5)
Defensive patterns
Strategy: type-guard
Type guard
def input_device?(src) src.is_a?(Selenium::WebDriver::Interactions::InputDevice) end # Pause accepts any InputDevice: Pause.new(src, duration) if input_device?(src)
Prevention
- Use device.create_pause(duration) instead of constructing Pause directly.
- Confirm custom input devices inherit InputDevice.
When it happens
Trigger: Constructing Interactions::Pause.new(source, duration) where source is not an InputDevice instance (e.g. a Symbol, a PointerInput subclass that does not extend InputDevice, or nil). Reachable via create_pause on an input device whose source was replaced.
Common situations: Custom interaction code that builds a Pause against the wrong object, or a subclassing mistake where a custom device forgets to inherit InputDevice.
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/e5c6b83ed8f0acca.
Report an issue: GitHub.