argent-macos-app-interact
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chineseargent-device-interactrun-sequenceawait-ui-elementargent-device-interactrun-sequenceawait-ui-elementContract
约定
- Needs the flag, which is on by default. When a tool says it is off, tell the user to run the command it names. Do not change the flag yourself.
macos-apps - One app is one device. shows only apps argent started that still run, also those of other sessions: never pick one unless the user named that app or this session started it.
list-devices - Start an app with , never with
boot-device {macosAppPath: "<abs path>.app"}or Xcode. Useopenonly for an app argent already started: with no recorded path it takes whichever copy Spotlight finds.launch-app - Build the without starting it:
.app, then take the bundle fromxcodebuild ... build(BUILT_PRODUCTS_DIR). Xcode Run andxcodebuild -showBuildSettingsstart a copy without the argent library:react-native run-macosthen fails withboot-device. Retry withalready running ... without the argent library, but ask the user first when they may have work open in that copy.force: true - Never pass when the error names another build path; report it.
force - After a code change: rebuild, then .
restart-app - A start result with a that the app showed no window: taps and screenshots need one. Tell the user, and read the log file it names.
note - On a hardened-runtime refusal, report it to the user. Do not sign files or change code signing.
- Never activate the app or drive it with ,
osascriptor other system tools.open - At the end: closes argent's connection; the app keeps running.
stop-all-simulator-servers {devices: ["macos-app-<bundle id>"]}
- 需要启用 flag,该 flag 默认开启。如果某个工具提示它未开启,应告知用户运行该工具指定的命令。不要自行修改此 flag。
macos-apps - 一个应用对应一个设备。仅显示由 argent 启动且仍在运行的应用,也包括其他会话中的应用:除非用户明确指定了某个应用,或该应用由当前会话启动,否则不要选择它。
list-devices - 使用 启动应用,绝不要使用
boot-device {macosAppPath: "<abs path>.app"}或 Xcode。仅对 argent 已经启动的应用使用open:如果没有记录路径,它会使用 Spotlight 找到的任意副本。launch-app - 构建 时不要启动应用:运行
.app,然后从xcodebuild ... build获取应用包(BUILT_PRODUCTS_DIR)。Xcode Run 和xcodebuild -showBuildSettings启动的应用副本不包含 argent library,随后执行react-native run-macos会失败并提示boot-device。可以使用already running ... without the argent library重试,但如果该副本中可能存在用户尚未保存的工作,应先询问用户。force: true - 如果错误信息指出了另一个构建路径,绝不要传入 ;应向用户报告该错误。
force - 修改代码后:重新构建,然后执行 。
restart-app - 如果启动结果中的 表示应用未显示窗口,点击和截图操作都需要一个可见窗口。应告知用户,并读取其中指定的日志文件。
note - 如果 hardened-runtime 拒绝执行,应向用户报告。不要签名文件或更改 code signing。
- 绝不要使用 、
osascript或其他系统工具激活或驱动应用。open - 最后执行 ,这会关闭 argent 的连接,但应用会继续运行。
stop-all-simulator-servers {devices: ["macos-app-<bundle id>"]}
Per-tool notes
各工具说明
- Swipe or drag: . Long press:
gesture-dragwith the same start and end point. Scroll:gesture-drag.gesture-scroll - Zoom or rotate: and
gesture-pinchfail; use the app's own controls or shortcuts.gesture-rotate - After a right-click (with
gesture-tap), the returned tree lists the menu items; a plainbutton: "right"on one chooses it (the menu can stay in the tree for a moment while it closes).gesture-tapkeyboardcloses the menu;escapechooses nothing after a right-click, so tap the item.enter - No hover: a tooltip is out of reach.
- : the URL goes to the running app. A custom scheme must be one the app declares;
open-urlandhttpgo to the app, not the browser; ahttpsURL opens that document in the app.file: - A SwiftUI opens only at its chevron, near the left end of its frame: a tap at the centre passes and does nothing. Tap along the left end in steps of about 0.008 until its
DisclosureGroupchanges.value - for any menu command. An item listed
menu-barcannot be chosen right now: an edit command (Copy, Select All) needs the text field clicked first; while an alert is open only its own commands work, so answer the alert first. When a menu of the app is open,[disabled]fails: sendchoose, then choose again.keyboard {key: "escape"} - Open and save panels: never click in the file list, which cannot read. Use
describe, also for the Delete or Don't Save prompt of an edited new document.file-panel
- 滑动或拖拽:使用 。长按:使用
gesture-drag,并将起点和终点设为同一位置。滚动:使用gesture-drag。gesture-scroll - 缩放或旋转:和
gesture-pinch无法使用;请改用应用自身的控件或快捷键。gesture-rotate - 右键点击(使用 并设置
gesture-tap)后,返回的 tree 中会列出菜单项;使用普通的button: "right"点击菜单项即可选择它(菜单关闭期间,菜单项可能会在 tree 中短暂保留)。gesture-tap的keyboard可关闭菜单;右键点击后,escape不会选择任何内容,因此应点击菜单项。enter - 不支持 hover:无法访问 tooltip。
- :URL 会传递给正在运行的应用。自定义 scheme 必须是应用已经声明的;
open-url和http会传递给应用,而不是浏览器;httpsURL 会让应用打开相应文档。file: - SwiftUI 只能通过其 chevron 展开,该 chevron 位于控件 frame 左端附近:点击中心位置会穿透且不会产生任何效果。沿左端以约 0.008 的步长逐步点击,直到其
DisclosureGroup发生变化。value - 任何菜单命令都应使用 。标记为
menu-bar的菜单项当前无法选择:编辑命令(Copy、Select All)需要先点击文本字段;当 alert 打开时,只有该 alert 自身的命令可用,因此应先处理 alert。应用菜单处于打开状态时,[disabled]会失败:先发送choose,然后再次选择。keyboard {key: "escape"} - 打开和保存面板:绝不要点击文件列表,因为 无法读取它。应使用
describe,编辑新文档后出现的 Delete 或 Don't Save 提示也应如此处理。file-panel
Tree
Tree
- Identifiers: AppKit accessibility identifier, SwiftUI , web
.accessibilityIdentifier()(elsedata-testid), React Nativeid(also on a plaintestIDorView).Text - Hint or
The Mac is locked: clicks and typing still work, elements can be missing (an open context menu among them), and afallback walkcheck cannot pass. Ask the user to unlock when a target is missing.hidden - An action that fails or has no effect: a minimized window takes no input. Restore it by choosing it in the Window menu with ; without such an item, ask the user.
menu-bar
- 标识符:AppKit accessibility identifier、SwiftUI 、Web
.accessibilityIdentifier()(否则为data-testid)、React Nativeid(也可设置在普通testID或View上)。Text - 当出现提示 或
The Mac is locked时:点击和输入仍然有效,但部分元素可能缺失(例如已打开的 context menu),并且fallback walk检查无法通过。如果目标元素缺失,应请用户解锁 Mac。hidden - 操作失败或没有效果:最小化的窗口无法接收输入。通过 在 Window 菜单中选择该窗口以恢复;如果没有对应菜单项,应询问用户。
menu-bar
E2E tests
E2E 测试
Read before recording or writing a test for a Mac app.
references/e2e.md为 Mac 应用录制或编写测试前,请阅读 。
references/e2e.mdreact-native-macos
react-native-macos
A Debug build loads JavaScript from Metro: start Metro before (see ). and the React profiler do not take a Mac app id: read the screen with .
boot-deviceargent-react-native-app-workflowdebugger-*describeDebug build 会从 Metro 加载 JavaScript:在执行 前启动 Metro(参见 )。 和 React profiler 不接受 Mac app id:请使用 读取屏幕。
boot-deviceargent-react-native-app-workflowdebugger-*describe