{"record":{"id":"e5c6b83ed8f0acca","repo":"SeleniumHQ/selenium","slug":"source-type-is-not-a-valid-input-type","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/pause.rb","lineNumber":38,"sourceCode":"module Selenium\n  module WebDriver\n    module Interactions\n      #\n      # Action to create a waiting period between actions\n      # Also used for synchronizing actions across devices\n      #\n      # @api private\n      #\n\n      class Pause < Interaction\n        def initialize(source, duration = nil)\n          super(source)\n          @duration = duration\n          @type = :pause\n        end\n\n        def assert_source(source)\n          raise TypeError, \"#{source.type} is not a valid input type\" unless source.is_a? InputDevice\n        end\n\n        def encode\n          output = {type: type}\n          output[:duration] = (@duration * 1000).to_i if @duration\n          output\n        end\n      end # Pause\n    end # Interactions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":20,"sourceCodeEnd":50,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/pause.rb#L20-L50","documentation":"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).","triggerScenarios":"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.","commonSituations":"Custom interaction code that builds a Pause against the wrong object, or a subclassing mistake where a custom device forgets to inherit InputDevice.","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."],"exampleFix":"# before\npause = Selenium::WebDriver::Interactions::Pause.new(:pointer, 0.5) # => TypeError\n\n# after\npointer = Selenium::WebDriver::Interactions::PointerInput.new(:mouse)\npause = Selenium::WebDriver::Interactions::Pause.new(pointer, 0.5)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def input_device?(src)\n  src.is_a?(Selenium::WebDriver::Interactions::InputDevice)\nend\n\n# Pause accepts any InputDevice:\nPause.new(src, duration) if input_device?(src)","tryCatchPattern":null,"preventionTips":["Use device.create_pause(duration) instead of constructing Pause directly.","Confirm custom input devices inherit InputDevice."],"tags":["interactions","pause","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"}