Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

role= selector vocabulary diverges from snapshot kind

Aperta
#3,021 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
45/100
Tipo di issue
Refactoring
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
testing

Direzione di ricerca

Read packages/kernel/src/snapshot.ts and the selector paths in packages/selectors/src/internal/match.ts and find.ts first. Decide the compatibility approach before changing behavior; if a cutover is chosen, update the selectors, the snapshot and client API documentation, and affected recorded-selector fixtures. Done means the rollout decision is documented and role= behavior and vocabulary are consistent with kind.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Context

#2656 added kind: string to structured snapshot nodes — the presenter's platform-neutral role vocabulary (button, text-field, text, switch, ...), computed by formatRole in packages/kernel/src/snapshot.ts and shared by every backend/projection.

Adversarial review of #2656 found that role= selector matching does not use that same vocabulary today, so the two completion conditions below cannot be satisfied without a separate, behavior-changing migration:

  • packages/selectors/src/internal/match.ts (role selector term) and packages/selectors/src/internal/find.ts (find role=... locator) each normalize node.type by stripping XCUIElementType/leaf-segment prefixes and lowercasing — producing raw leaf class names (statictext, edittext, textfield) rather than formatRole's coarse vocabulary (text, text-field).
  • packages/provider-webdriver/src/webdriver-source.ts (roleFromWebDriverType) independently falls back to a similarly-stripped type name when WebDriver's class attribute is absent, to populate the (iOS AX-derived) role field — a different field than kind, but the same kind of ad hoc normalization.
  • packages/contracts/src/snapshot-text.ts (normalizeType) strips the same prefixes for a different purpose (fillable-type/keyboard-occlusion detection), so it is a distinct concern from role classification but shares the pattern.

Why this is its own issue, not folded into #2656

role= selector matching is a released, public selector feature (shipped before 0.21.x). Switching it to formatRole's vocabulary would change matching results for existing selectors and recorded scripts (e.g. role=statictext and role=edittext would stop matching; role=text/role=text-field would start). That is a breaking change to a versioned surface and needs an explicit compatibility/rollout decision (hard fail vs. an aliasing period), which is out of scope for a PR whose job is adding the kind field.

Proposed work

  • Decide whether role= (both the main selector term and the find locator) should match against formatRole(node.type) instead of raw leaf-class normalization, and whether that is a hard cutover or needs a deprecation window.
  • If cutover: update packages/selectors/src/internal/match.ts and packages/selectors/src/internal/find.ts to import and use formatRole from @agent-device/kernel/snapshot, delete the now-redundant normalizeRole in find.ts, update website/docs/docs/snapshots.md and website/docs/docs/client-api.md to state role= shares kind's vocabulary, and sweep recorded-selector/doc fixtures that assume the old raw vocabulary.
  • Leave packages/contracts/src/snapshot-text.ts#normalizeType (fillable/occlusion detection) and packages/provider-webdriver/src/webdriver-source.ts#roleFromWebDriverType (the iOS role field fallback) alone unless the decision above says otherwise — they serve different fields/purposes than kind.

References

  • #2656
Lingua principale
TypeScript
Stelle
4.8k
Fork
315
Merge medio
11h 25m
PR unite (30g)
545

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di callstack/agent-device

Tutte le issue di callstack/agent-device

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.