Skip to content

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”.

NameTypeRequiredDefaultConstraintsDescription
action`enum: presslongPresstypeTextscrollsetFieldValue`
testIDstringNotestID 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.
accessibilityLabelstringNoaccessibilityLabel prop (used if testID not provided). Tiered match: exact → normalized (trim+lowercase) → substring. Returns Ambiguous error if >1 component matches.
textstringNoRequired for typeText: the text to enter
scrollXnumberNoFor scroll: horizontal offset in pixels (default 0)
scrollYnumberNoFor scroll: vertical offset in pixels (default 300)
animatedbooleanNotrueFor scroll: whether to animate
namestringNoRequired for setFieldValue: the React Hook Form field name (same string you passed to useController({name}) or <Controller name=”…”>).
valueunknownNoRequired for setFieldValue: the value to set. Passed verbatim to setValue; no coercion.
shouldValidatebooleanNoFor setFieldValue: pass-through to setValue\‘s options.shouldValidate (default true). Set false to suppress synchronous validation.
shouldDirtybooleanNoFor 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>)