Skip to content

Reference

cdp_interact

Interact with React components by testID, accessibilityLabel, or supported discovery facts. Calls JS handlers directly, not native touch. typeText joins every matching source to exact eligible handler-owning fibers under one cycle-safe 2,000-work-unit limit and refuses incomplete or ambiguous resolution; success proves one exact React handler dispatch, not native keyboard or input fidelity. It accepts placeholder or role+name, and generic onChange is eligible only on a proven native text-input host Fiber. accessibilityLabel matching uses exact, normalized, then substring tiers. setFieldValue walks to the nearest FormProvider, or safely matches an explicit control prop to an ancestor useForm hook return by object identity before calling setValue. Portal roots can be registered through globalThis.RN_AGENT_EXTRA_ROOTS. walkUp (opt-in): for action:“press” with testID/accessibilityLabel selectors only, walks up at most 8 fiber ancestors to the nearest pressable and refuses absence or ambiguity. Use device_swipe/device_press for native gestures.

NameTypeRequiredDefaultConstraintsDescription
actionenum: press | longPress | typeText | scroll | setFieldValueYesAction: press, longPress, typeText, scroll, or React Hook Form setFieldValue.
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.
textstringNoText to enter, or visible text selector for press.
rolestringNoAccessibility role selector; for typeText combine with name.
placeholderstringNoMatch a TextInput placeholder for press or typeText.
exactbooleanNoDiscovery ladder: require an exact (full-string) match for text/name/placeholder instead of case-insensitive substring.
includeHiddenbooleanNoDiscovery ladder: include accessibility-hidden elements (excluded by default).
scrollXnumberNoFor scroll: horizontal offset in pixels (default 0)
scrollYnumberNoFor scroll: vertical offset in pixels (default 300)
animatedbooleanNotrueFor scroll: whether to animate
namestringNoReact Hook Form field name, or accessible name paired with role.
valueunknownNoValue to set. For setFieldValue: passed to setValue (a digit-string is kept a string when the field currently holds a string — give string fields a "" default so this applies). For press: when provided, onPress receives this value instead of a synthetic event — use for radio/chip-style value-bearing controls.
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.
walkUpbooleanNoOpt-in press-only nearest-pressable-ancestor walk
cdp_interact(action: <enum: press | longPress | typeText | scroll | setFieldValue>)