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 PointerPress#assert_source when the source passed to PointerPress.new(source, direction, button, **opts) is not a PointerInput. PointerPress encodes pointerDown/pointerUp and is only valid on a pointer source; it also mixes in PointerEventProperties.

Source

Thrown at rb/lib/selenium/webdriver/common/interactions/pointer_press.rb:59

                   forward: 4}.freeze
        DIRECTIONS = {down: :pointerDown, up: :pointerUp}.freeze

        def initialize(source, direction, button, **opts)
          super(source)
          @direction = assert_direction(direction)
          @button = assert_button(button)
          @type = @direction
          @opts = opts
        end

        def encode
          process_opts.merge('type' => type.to_s, 'button' => @button)
        end

        private

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

        def assert_button(button)
          case button
          when Symbol
            raise ArgumentError, "#{button} is not a valid button!" unless BUTTONS.key? button

            BUTTONS[button]
          when Integer
            raise ArgumentError, 'Button number cannot be negative!' if button.negative?

            button
          else
            raise TypeError, "button must be a positive integer or one of #{BUTTONS.keys}, not #{button.class}"
          end
        end

        def assert_direction(direction)

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Use pointer_input.create_pointer_down(button, **) / create_pointer_up(button, **) so the correct source is passed.
  2. Confirm source.is_a?(Selenium::WebDriver::Interactions::PointerInput) before constructing PointerPress.

Example fix

# before
press = Selenium::WebDriver::Interactions::PointerPress.new(key_input, :down, :left) # => TypeError

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

Strategy: type-guard

Type guard

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

PointerPress.new(src, dir, btn, **opts) if pointer_input?(src)

Prevention

When it happens

Trigger: Constructing Interactions::PointerPress.new(source, :down, :left, ...) with a non-PointerInput source, e.g. a WheelInput or KeyInput. Reached via PointerInput#create_pointer_down / create_pointer_up (which pass self) or direct construction.

Common situations: Hand-built action sequences that wire a press onto a wheel device; refactors that alias the wrong device variable.

Related errors


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