cdp_interact
Interact with React components by testID (preferred) or accessibilityLabel — press buttons, long-press, type text, scroll, or set a React Hook Form field value directly. Calls JS handlers directly (not native touch). testID matches strictly; accessibilityLabel matches in tiers (exact → trim/case-insensitive → substring) and returns an ambiguity error when >1 component matches. Prefer testID for unambiguous targeting. For native gestures (swipe, drag), use device_swipe/device_press instead. setFieldValue (GH #126 Gap A): explicit fallback when typeText fails because the field routes through a Controller — pass name + value, walks UP to the nearest FormProvider and calls its setValue. Use only when typeText returns “no handler”.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
action | `enum: press | longPress | typeText | scroll | setFieldValue` |
testID | string | No | testID prop of the target component (strict match — preferred). For setFieldValue, this is the testID anchor inside the form\‘s subtree from which to walk up. | ||
accessibilityLabel | string | No | accessibilityLabel prop (used if testID not provided). Tiered match: exact → normalized (trim+lowercase) → substring. Returns Ambiguous error if >1 component matches. | ||
text | string | No | Required for typeText: the text to enter | ||
scrollX | number | No | For scroll: horizontal offset in pixels (default 0) | ||
scrollY | number | No | For scroll: vertical offset in pixels (default 300) | ||
animated | boolean | No | true | For scroll: whether to animate | |
name | string | No | Required for setFieldValue: the React Hook Form field name (same string you passed to useController({name}) or <Controller name=”…”>). | ||
value | unknown | No | Required for setFieldValue: the value to set. Passed verbatim to setValue; no coercion. | ||
shouldValidate | boolean | No | For setFieldValue: pass-through to setValue\‘s options.shouldValidate (default true). Set false to suppress synchronous validation. | ||
shouldDirty | boolean | No | For setFieldValue: pass-through to setValue\‘s options.shouldDirty (default true). Set false to keep the field marked pristine. |
cdp_interact(action: <enum: press | longPress | typeText | scroll | setFieldValue>)