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.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Constraints | Description |
|---|---|---|---|---|---|
action | enum: press | longPress | typeText | scroll | setFieldValue | Yes | Action: press, longPress, typeText, scroll, or React Hook Form 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 | Text to enter, or visible text selector for press. | ||
role | string | No | Accessibility role selector; for typeText combine with name. | ||
placeholder | string | No | Match a TextInput placeholder for press or typeText. | ||
exact | boolean | No | Discovery ladder: require an exact (full-string) match for text/name/placeholder instead of case-insensitive substring. | ||
includeHidden | boolean | No | Discovery ladder: include accessibility-hidden elements (excluded by default). | ||
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 | React Hook Form field name, or accessible name paired with role. | ||
value | unknown | No | Value 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. | ||
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. | ||
walkUp | boolean | No | Opt-in press-only nearest-pressable-ancestor walk |
cdp_interact(action: <enum: press | longPress | typeText | scroll | setFieldValue>)