Act on a mini program element
mp_element_actionActs on one selected page element—tap, longpress, input, trigger events, scroll, swipe, slide, or call a component method—re-resolves the selector each call and returns the result plus current page.
Instructions
Act on one element of the current page: tap, longpress, input text, trigger an event, send a raw touch, scroll a scroll-view, swipe a swiper, slide a slider, or call a custom component method. The element is re-resolved from its selector on every call, so actions are replayable; a miss reports the neighbouring elements that did render. Returns the action result and the page you are on afterwards.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"selector": "<selector>",
"action": "<action>"
},
"name": "mp_element_action"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| args | No | Arguments for action "call_method". | |
| data | No | Data object for action "set_data" on a custom component. | |
| event | No | Event name for action "trigger", e.g. "confirm" or a custom event. | |
| index | No | Zero-based match to act on when the selector hits several elements. | |
| value | No | Text to type, for action "input". | |
| xpath | No | Treat selector as XPath. | |
| action | Yes | What to do with the element. | |
| detail | No | Event detail object forwarded to the app for action "trigger". | |
| method | No | Component method name for action "call_method". | |
| touch_x | No | pageX/clientX for touch actions. | |
| touch_y | No | pageY/clientY for touch actions. | |
| selector | Yes | WXML/CSS selector for the element, e.g. ".submit" or "view.title". | |
| x_position | No | Horizontal target for action "scroll_to". | |
| y_position | No | Vertical target for action "scroll_to". | |
| target_index | No | Swiper index for "swipe_to", or slider value for "slide_to". | |
| container_selector | No | Resolve this selector first, then search inside it. |