SeleniumHQ/selenium · error · InvalidArgumentException

Invalid PointerInput kind '{kind}'

Error message

Invalid PointerInput kind '{kind}'

What it means

`PointerInput.__init__` validates that `kind` is one of the allowed pointer kinds (`POINTER_KINDS = {"mouse", "touch", "pen"}`). Any other value raises `InvalidArgumentException`. The pointer type is sent verbatim to the W3C actions endpoint, so an invalid kind would be rejected by the driver anyway; Selenium rejects it early.

Source

Thrown at py/selenium/webdriver/common/actions/pointer_input.py:32

# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.

from typing import Any

from selenium.common.exceptions import InvalidArgumentException
from selenium.webdriver.common.actions.input_device import InputDevice
from selenium.webdriver.common.actions.interaction import POINTER, POINTER_KINDS
from selenium.webdriver.remote.webelement import WebElement


class PointerInput(InputDevice):
    DEFAULT_MOVE_DURATION = 250

    def __init__(self, kind, name):
        super().__init__()
        if kind not in POINTER_KINDS:
            raise InvalidArgumentException(f"Invalid PointerInput kind '{kind}'")
        self.type = POINTER
        self.kind = kind
        self.name = name

    def create_pointer_move(
        self,
        duration=DEFAULT_MOVE_DURATION,
        x: float = 0,
        y: float = 0,
        origin: WebElement | None = None,
        **kwargs,
    ):
        action = {"type": "pointerMove", "duration": duration, "x": x, "y": y, **kwargs}
        if isinstance(origin, WebElement):
            action["origin"] = {"element-6066-11e4-a52e-4f735466cecf": origin.id}
        elif origin is not None:
            action["origin"] = origin
        self.add_action(self._convert_keys(action))

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Use a valid kind from selenium.webdriver.common.actions.interaction: POINTER_MOUSE/POINTER_TOUCH/POINTER_PEN ("mouse", "touch", "pen").
  2. Reference the constants instead of hardcoding: `from selenium.webdriver.common.actions.interaction import POINTER_PEN; PointerInput(POINTER_PEN, "pen")`.
  3. For a stylus, use "pen".

Example fix

// before
PointerInput("MOUSE", "mouse1")  # InvalidArgumentException - case
// after
from selenium.webdriver.common.actions.interaction import POINTER_MOUSE
PointerInput(POINTER_MOUSE, "mouse1")
Defensive patterns

Strategy: validation

Validate before calling

from selenium.webdriver.common.actions.interaction import POINTER_KINDS
kind = "mouse"
assert kind in POINTER_KINDS, f"kind must be one of {POINTER_KINDS}"
PointerInput(kind, "mouse1")

Type guard

from selenium.webdriver.common.actions.interaction import POINTER_KINDS
def is_valid_pointer_kind(kind: str) -> bool:
    return kind in POINTER_KINDS

Try / catch

from selenium.common.exceptions import InvalidArgumentException
try:
    pi = PointerInput(kind, name)
except InvalidArgumentException:
    pi = PointerInput("mouse", name)  # default to mouse

Prevention

When it happens

Trigger: `PointerInput("keyboard", "name")`, `PointerInput("MOUSE", "name")` (case sensitivity), `PointerInput("stylus", "name")`, or `PointerInput("", "name")`. The valid set is exactly {mouse, touch, pen}.

Common situations: Using uppercase by mistake. Trying to use "stylus"/"pen-tablet" (use "pen"). Custom action-builder code that constructs PointerInput directly. Version drift where a kind was renamed.

Related errors


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