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 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.

Source

Thrown at rb/lib/selenium/webdriver/common/interactions/pointer_cancel.rb:36

# under the License.

module Selenium
  module WebDriver
    module Interactions
      #
      # Action to cancel any other Pointer Action.
      #
      # @api private
      #

      class PointerCancel < Interaction
        def initialize(source)
          super
          @type = :pointerCancel
        end

        def assert_source(source)
          raise TypeError, "#{source.type} is not a valid input type" unless source.is_a? PointerInput
        end

        def encode
          {type: type}
        end
      end # PointerCancel
    end # Interactions
  end # WebDriver
end # Selenium

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Use pointer_input.create_pointer_cancel (which passes itself as source) instead of constructing PointerCancel directly.
  2. Confirm the source is_a?(Selenium::WebDriver::Interactions::PointerInput) before building the cancel.

Example fix

# before
cancel = Selenium::WebDriver::Interactions::PointerCancel.new(wheel_input) # => TypeError

# after
pointer = Selenium::WebDriver::Interactions::PointerInput.new(:mouse)
cancel = Selenium::WebDriver::Interactions::PointerCancel.new(pointer)
Defensive patterns

Strategy: type-guard

Type guard

def pointer_input?(src)
  src.is_a?(Selenium::WebDriver::Interactions::PointerInput)
end

PointerCancel.new(src) if pointer_input?(src)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/d4d5422c2947cd6f. Report an issue: GitHub.