SeleniumHQ/selenium · error · TypeError
# is not a valid pointer type
Error message
#{pointer.inspect} is not a valid pointer type What it means
Raised as TypeError by PointerInput#assert_kind when the kind passed to PointerInput.new(kind, name:) is not a key in KIND. KIND permits exactly :mouse, :pen, :touch (each maps to itself as the wire pointerType). The check happens in the constructor, so the error fires at device creation, not at action perform time.
Solutions
- Use one of the three Symbols: :mouse, :pen, or :touch.
- If you hold the kind in a variable, symbolize and validate: kind = kind.to_sym and check PointerInput::KIND.key?(kind) before constructing.
Example fix
# before pointer = Selenium::WebDriver::Interactions::PointerInput.new(:finger) # => TypeError # after pointer = Selenium::WebDriver::Interactions::PointerInput.new(:touch)
Defensive patterns
Strategy: validation
Validate before calling
KIND = Selenium::WebDriver::Interactions::PointerInput::KIND
kind = kind.to_sym
raise "unsupported pointer kind: #{kind}" unless KIND.key?(kind)
pointer = Selenium::WebDriver::Interactions::PointerInput.new(kind) Type guard
def valid_pointer_kind?(k) Selenium::WebDriver::Interactions::PointerInput::KIND.key?(k.is_a?(Symbol) ? k : k.to_sym) end
Prevention
- Use only :mouse, :pen, :touch.
- Symbolize external kind values and validate against PointerInput::KIND before constructing the device.
When it happens
Trigger: Constructing PointerInput.new(:stylus), PointerInput.new('mouse') (String instead of Symbol), PointerInput.new(:finger), or any value outside {mouse, pen, touch}.
Common situations: Appium/W3C examples that use 'finger'/'stylus' (not supported here); passing a String constant; building a custom PointerInput for a touch test on desktop where only :mouse makes sense.
Related errors
- # is not a valid action
- button must be a positive integer or one of #
- # is not a #
- # is not a valid button!
- Button number cannot be negative!
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/4c331f097bf8fec8.
Report an issue: GitHub.
Appendix: source
Thrown at rb/lib/selenium/webdriver/common/interactions/pointer_input.rb:47
class PointerInput < InputDevice
KIND = {mouse: :mouse, pen: :pen, touch: :touch}.freeze
attr_reader :kind
def initialize(kind, name: nil)
super(name)
@kind = assert_kind(kind)
@type = Interactions::POINTER
end
def encode
output = super
output[:parameters] = {pointerType: kind} if output
output
end
def assert_kind(pointer)
raise TypeError, "#{pointer.inspect} is not a valid pointer type" unless KIND.key? pointer
KIND[pointer]
end
def create_pointer_move(duration: 0, x: 0, y: 0, origin: nil, **)
add_action(PointerMove.new(self, duration, x, y, origin: origin, **))
end
def create_pointer_down(button, **)
add_action(PointerPress.new(self, :down, button, **))
end
def create_pointer_up(button, **)
add_action(PointerPress.new(self, :up, button, **))
end
def create_pointer_cancel
add_action(PointerCancel.new(self))View on GitHub (pinned to aa36b38e69)