[v4]: unify selector type

Merged
SE
8mo ago
+216-231

why

  • to unify selector into a single field across page request bodies
  • this groups semantically similar fields into a shared & reusable type

what changed

  • replaced PageSelectorSchema (xpath-only object) with a discriminated union of 4 selector types:
    • PageXPathSelectorSchema,
    • PageCssSelectorSchema,
    • PageTextSelectorSchema,
    • PageCoordinateSelectorSchema
  • added PageElementSelectorSchema (xpath/css/text, no coordinates) for waitForSelector
  • collapsed the dual *SelectorParams / *CoordinatesParams schema pairs for click, hover, scroll, and dragAndDrop into single schemas with a unified selector field

example /hover before:

Screenshot 2026-03-19 at 1 39 06 PM

example /hover after:

Screenshot 2026-03-19 at 1 41 14 PM

test plan

  • added integration tests for css, text, and coordinate selector types

Summary by cubic

Unifies the v4 page selector into a single selector union and adds css, text, and coordinate options. This simplifies request bodies and makes click, hover, scroll, and drag‑and‑drop consistent.

  • New Features

    • One selector union for all page actions: xpath, css, text, or coordinates.
    • Introduced Selector and ElementSelector unions; split former PageSelector into XPathSelector, CssSelector, TextSelector, and CoordinateSelector.
    • Added ElementSelector (xpath/css/text) for element‑only cases like waitForSelector and scroll‑by‑percentage; exported PageScrollElementParams and PageScrollCoordinateParams.
    • dragAndDrop supports mixing selector types (e.g., xpath → coordinates).
    • Added integration tests for css, text, coordinate selectors, and mixed drag‑and‑drop.
  • Migration

    • click/hover: always send { selector: { xpath|css|text|x,y } }. Remove top‑level x/y.
    • scroll: use element selector + percentage, or coordinate selector + deltaY.
    • dragAndDrop: from/to now use the unified selector (elements or coordinates).
    • waitForSelector: use ElementSelector (no coordinates).