{"record":{"id":"d4d5422c2947cd6f","repo":"SeleniumHQ/selenium","slug":"source-type-is-not-a-valid-input-type-d4d542","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_cancel.rb","lineNumber":36,"sourceCode":"# under the License.\n\nmodule Selenium\n  module WebDriver\n    module Interactions\n      #\n      # Action to cancel any other Pointer Action.\n      #\n      # @api private\n      #\n\n      class PointerCancel < Interaction\n        def initialize(source)\n          super\n          @type = :pointerCancel\n        end\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 encode\n          {type: type}\n        end\n      end # PointerCancel\n    end # Interactions\n  end # WebDriver\nend # Selenium\n","sourceCodeStart":18,"sourceCodeEnd":46,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/interactions/pointer_cancel.rb#L18-L46","documentation":"Raised as TypeError by PointerCancel#assert_source when the source passed to PointerCancel.new(source) is not a PointerInput. PointerCancel encodes a W3C pointerCancel action and is only valid on a pointer input source, hence the stricter check than Pause.","triggerScenarios":"Constructing Interactions::PointerCancel.new(source) with a source that is a KeyInput, WheelInput, NoneInput, or non-InputDevice object. Typically reached through PointerInput#create_pointer_cancel when the device was swapped, or via direct construction.","commonSituations":"Custom action building that wires a cancel onto the wrong device type, or a test that reuses a key/wheel device reference where a pointer was expected.","solutions":["Use pointer_input.create_pointer_cancel (which passes itself as source) instead of constructing PointerCancel directly.","Confirm the source is_a?(Selenium::WebDriver::Interactions::PointerInput) before building the cancel."],"exampleFix":"# before\ncancel = Selenium::WebDriver::Interactions::PointerCancel.new(wheel_input) # => TypeError\n\n# after\npointer = Selenium::WebDriver::Interactions::PointerInput.new(:mouse)\ncancel = Selenium::WebDriver::Interactions::PointerCancel.new(pointer)","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"def pointer_input?(src)\n  src.is_a?(Selenium::WebDriver::Interactions::PointerInput)\nend\n\nPointerCancel.new(src) if pointer_input?(src)","tryCatchPattern":null,"preventionTips":["Use pointer_input.create_pointer_cancel so the device passes itself as the source.","Keep pointer actions wired only to PointerInput instances."],"tags":["interactions","pointer-cancel","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"}