首页/移动开发/argent-device-interact
A

argent-device-interact

by @software-mansionv
4.6(1)

通过 argent MCP 工具操控 iOS 模拟器与 Android 模拟器,支持点击、手势、输入、截图与应用状态检查,提升移动测试效率。

ios-developmentandroid-developmentmobile-testingemulator-automationsimulator-interactionGitHub
安装方式
npx skills add https://github.com/software-mansion/argent --skill argent-device-interact
compare_arrows

Before / After 效果对比

1 组
使用前

在没有这个技能之前,用户需要手动在 iOS 模拟器或 Android 模拟器上执行点击、滑动、输入文本、启动应用等操作。这不仅耗时,而且容易出错,尤其是在进行重复性测试或需要大规模操作时,效率低下且难以保证一致性。

使用后

此技能能够自动化所有与 iOS 模拟器或 Android 模拟器的交互,包括 UI 元素点击、手势操作、文本输入、应用启动和状态检查。这极大地减少了手动操作的时间和错误,使得测试和开发流程更加高效、准确和可重复。

SKILL.md

Unified tool surface

All interaction tools below accept a udid parameter and auto-dispatch iOS vs Android based on its shape (UUID → iOS simulator, anything else → Android adb serial). You use the same tool names on both platforms.

For platform-specific caveats (Metro adb reverse, locked-screen describe errors, etc.), see § 9 Platform-specific notes at the bottom.

1. Before You Start

If you delegate simulator tasks to sub-agents, make sure they have MCP permissions.

Use list-devices to get a target id. Results are tagged with platform (ios or android); booted/ready devices come first. Pick the first entry that matches the platform you need — if none are ready, call boot-device with udid (iOS) or avdName (Android). See argent-ios-simulator-setup / argent-android-emulator-setup for full setup flow.

Load tool schemas before first use. Gesture tools (gesture-tap, gesture-swipe, gesture-pinch, gesture-rotate, gesture-custom) may be deferred — their parameter schemas are not loaded until fetched. Always use ToolSearch to load the schemas of all gesture tools you plan to use before calling any of them. If you skip this step, parameters may be coerced to strings instead of numbers, causing validation errors.

2. Best Practices

  1. Always refer to tapping_rule from your argent.md rule before tapping.
  2. Before performing interactions, consider whether they can be dispatched sequentially - more on that in run-sequence.
  3. Use gesture-swipe for lists/scrolling, not gesture-custom, unless you need non-linear movement. Consider whether you need multiple swipes, if yes - use run-sequence.
  4. Tap a text field before typing — on iOS try paste first then fall back to keyboard; on Android use keyboard directly (paste is iOS-only).
  5. Coordinates are normalized — always 0.0–1.0, not pixels.
  6. For app navigation, prefer describe first. It works on any screen without app restart. Do not navigate from screenshots on regular in-app screens unless describe failed to expose a reliable target. Use native-describe-screen only when you need app-scoped UIKit properties.

3. Opening Apps

Never navigate to an app by tapping home-screen icons. Use launch-app or open-url — they are instant and reliable.

launch-app — by bundle ID

{ "udid": "<UDID>", "bundleId": "com.apple.MobileSMS" }

Common IDs: com.apple.MobileSMS (Messages), com.apple.mobilesafari (Safari), com.apple.Preferences (Settings), com.apple.Maps, com.apple.Photos, com.apple.mobilemail, com.apple.mobilenotes, com.apple.MobileAddressBook (Contacts)

open-url — by URL scheme

{ "udid": "<UDID>", "url": "messages://" }

Common schemes: messages://, settings://, maps://?q=<query>, tel://<number>, mailto:<address>, https://... (Safari)

4. Choosing the Right Tool

ActionToolNotes
Multiple actionsrun-sequenceBatch steps in one call (no intermediate screenshots)
Open an applaunch-appAlways — never tap home-screen icons
Restart an apprestart-appTerminate and relaunch by bundle ID
Open URL/schemeopen-urlWeb pages, deep links, URL schemes
Single tapgesture-tapButtons, links, checkboxes
Scroll/swipegesture-swipeStraight-line scroll or swipe
Long pressgesture-customContext menus, drag start
Drag & dropgesture-customComplex drag interactions
Pinch/zoomgesture-pinchTwo-finger pinch with auto-interpolation
Rotationgesture-rotateTwo-finger rotation with auto-interpolation
Custom gesturegesture-customArbitrary touch sequences, optional interpolation
Hardware keybuttonHome, back, power, volume, appSwitch, actionButton
Type text (fast)pasteiOS only. Form fields — uses clipboard
Type textkeyboardiOS+Android. Fallback when paste fails; supports Enter, Escape, arrows
Rotate devicerotateOrientation changes

5. Finding Tap Targets

IMPORTANT. When moved to a different screen after an action or do not know the coordinates of component, always perform proper discovery first.

App typeDiscovery toolWhat it returns
Target app discoverydescribeAccessibility element tree for the current device screen (iOS AX-service or Android uiautomator) with normalized frame coordinates. Works on any app, system dialogs, and Home screen — no app restart or bundleId required
React Nativedebugger-component-treeReact component tree with names, text, testID, and (tap: x,y)
App-scoped nativenative-describe-screenLow-level app-scoped accessibility elements with normalized and raw coordinates; requires bundleId
Permission / system modal overlaydescribedescribe detects system dialogs automatically and returns dialog buttons with tap coordinates. Fall back to screenshot only if describe does not expose the controls
Final visual fallbackscreenshotUse only when discovery tools cannot inspect the current UI reliably. Do not derive routine in-app navigation targets from screenshots

Point follow-up native diagnostics after you already have a candidate point:

  • native-user-interactable-view-at-point: deepest native view that would receive touch at a known raw iOS point; requires bundleId
  • native-view-at-point: deepest visible native view at a known raw iOS point; requires bundleId

If describe Fails

Read the exact error and choose the action that matches it:

  • Error mentions ax-service not available or daemon startup failure: the ax-service daemon could not start. Check that the simulator is booted. Use screenshot as a temporary fallback, or use native-describe-screen with an explicit bundleId if the app has native devtools injected.
  • describe returns an empty element list: the screen may be blank, loading, or showing content without accessibility labels. Use screenshot to see what is visible, then retry after the content has loaded.
  • describe succeeds but is not detailed enough for a React Native app: use debugger-component-tree next.
  • You need app-scoped inspection with full UIKit properties (accessibilityIdentifier, viewClassName): use native-describe-screen with an explicit bundleId. This requires native devtools (dylib) injection — call restart-app first if needed.
  • You already have a candidate point and want to confirm what would actually receive touch: use native-user-interactable-view-at-point. Use native-view-at-point when you want the visually deepest view instead of the hit-test target.

6. Tool Usage

gesture-tap — Single tap at a point

{ "udid": "<UDID>", "x": 0.5, "y": 0.5 }

Coordinates: 0.0 = left/top, 1.0 = right/bottom.

Before tapping near the bottom of the screen in React Native apps, check that "Open Debugger to View Warnings" banners are not visible — tapping them breaks the debugger connection. Close them with the X icon if present.

gesture-swipe — Straight-line gesture

{ "udid": "<UDID>", "fromX": 0.5, "fromY": 0.7, "toX": 0.5, "toY": 0.3 }

Swipe up (fromY > toY) = scroll content down. Default duration: 300ms. Optional: "durationMs": 500 for slower swipe.

gesture-pinch — Two-finger pinch

{ "udid": "<UDID>", "centerX": 0.5, "centerY": 0.5, "startDistance": 0.2, "endDistance": 0.6 }

All values are normalized 0.0–1.0 (fractions of screen, not pixels) — same as all other gesture tools. startDistance: 0.2 means fingers start 20% of the screen apart; endDistance: 0.6 means they end 60% apart. startDistance < endDistance = pinch out (zoom in). startDistance > endDistance = pinch in (zoom out). Defaults: angle: 0 (horizontal), durationMs: 300. Optional: "angle": 90 for vertical axis, "durationMs": 500 for slower pinch.

gesture-rotate — Two-finger rotation

{
  "udid": "<UDID>",
  "centerX": 0.5,
  "centerY": 0.5,
  "radius": 0.15,
  "startAngle": 0,
  "endAngle": 90
}

All positions and radius are normalized 0.0–1.0 (fractions of screen, not pixels). radius: 0.15 means each finger is 15% of the screen away from center. endAngle > startAngle = clockwise. Default duration: 300ms. Optional: "durationMs": 500 for slower rotation.

gesture-custom — Custom touch sequence

For long-press, drag-and-drop, and other complex sequences, see references/gesture-examples.md. Set "interpolate": 10 to auto-generate smooth intermediate Move events between keyframes.

button — Hardware button press

{ "udid": "<UDID>", "button": "home" }

Values: home, back, power, volumeUp, volumeDown, appSwitch, actionButton

paste — Type text into focused field (iOS only)

{ "udid": "<UDID>", "text": "Hello, world!" }

Tap the field first, then paste. Fall back to keyboard if it doesn't work. On Android the call is rejected by the capability gate ("Tool 'paste' is not supported on android") — use keyboard directly.

keyboard — Type text or press special keys

{ "udid": "<UDID>", "text": "search query", "key": "enter" }

Special keys: enter, escape, backspace, tab, space, arrow-up, arrow-down, arrow-left, arrow-right, f1–f12. Optional: "delayMs": 100 between keystrokes (default 50ms).

rotate — Change orientation

{ "udid": "<UDID>", "orientation": "LandscapeLeft" }

Values: Portrait, LandscapeLeft, LandscapeRight, PortraitUpsideDown


7. Screenshots

Use the explicit screenshot tool only when:

  • You need the initial screen state before any action.
  • You are about to edit visible UI and need a baseline capture before making changes.
  • The auto-attached screenshot shows a transitional or loading frame.
  • You require extra context.
  • You want to check state after a delay (e.g. waiting for a network response).
  • A permission dialog, system alert, or native modal overlay is visible and describe did not expose reliable targets.

When using screenshot for permission or native modal navigation:

  • Do not switch to screenshot-driven navigation just because a modal is visible. On regular app screens and in-app modals, keep using describe.
  • Prefer obvious, centered alert buttons such as Allow, OK, Don't Allow, Not Now, or Continue.
  • Tap one control at a time and inspect the returned auto-screenshot before doing anything else.
  • After the modal is dismissed, return to normal discovery with describe, native-describe-screen, or debugger-component-tree.

Optional rotation parameter: { "udid": "<UDID>", "rotation": "LandscapeLeft" } — rotates the capture without changing simulator orientation.

Screenshots are downscaled by default (30% of original resolution) to reduce context size. Use the normal downscaled screenshot for UI context and state checks. scale accepts values from 0.01 to 1.0, but do not use scale: 1.0 as a general readability or tapping aid.

Use full-resolution screenshots only when saving baseline/current PNG files for comparison. In that case, suppress the image block so the full-size PNG is not loaded into agent context:

{ "udid": "<UDID>", "scale": 1.0, "includeImageInContext": false }

For visual regression checks, before/after screenshot comparisons, and detailed screenshot-diff parameter guidance, use the argent-screenshot-diff skill. Keep this skill focused on device interaction mechanics and screenshot capture.

Troubleshooting

ProblemSolution
Screenshot times outRestart the simulator-server via stop-simulator-server tool
No booted iOS simulatorCall boot-device with the iOS udid
No ready Android deviceCall boot-device with avdName

8. Action Sequencing with run-sequence

Use run-sequence to batch multiple interaction steps into a single tool call. Only one screenshot is returned — after all steps complete. Use cases: scrolling multiple times, typing and submitting automatically, known sequence of multiple taps, rotating device back and forth.

Do not use run-sequence when any step depends on observing the result of a previous step

Use cases

Use the sequencing when:

  • Knowing that some action needs multiple steps without necessarily immediate insight of screenshot
  • "scroll to bottom", "scroll to top", "scroll to do X" -> sequence scroll 3-5 times
  • form interactions, "clear and retype field" -> you may use triple-tap to select all, type new value
  • "submit form" → fill all fields in sequence, tap submit
  • "go back to X" → defined tap sequence for the navigation

Allowed tools inside run-sequence

gesture-tap, gesture-swipe, gesture-custom, gesture-pinch, gesture-rotate, button, keyboard, rotate

The udid is shared — do not include it

...

用户评价 (0)

发表评价

效果
易用性
文档
兼容性

暂无评价

统计数据

安装量25.7K
评分4.6 / 5.0
版本
更新日期2026年10月23日
对比案例1 组

用户评分

4.6(1)
5
100%
4
0%
3
0%
2
0%
1
0%

为此 Skill 评分

0.0

兼容平台

🤖claude-code

时间线

创建2026年6月9日
最后更新2026年10月23日
🎁 Agent 知识卡片
调研问卷