Files
agent_admin/docs/agent/actions/back.md
T

72 lines
1.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# BACK
> [返回动作目录](README.md) · [任务协议](../protocol.md) · [执行与结果](../execution.md)
## 1. 当前行为 **[已实现]**
~~~json
{
"id": "go-back",
"action": "BACK",
"packageName": "com.example.target",
"timeoutMs": 3000
}
~~~
当前 BACK:
- 不需要 selector。
- 等待前台包和可选 Activity 匹配。
- 调用 `GLOBAL_ACTION_BACK`。
- 不验证返回后的页面。
- 调用返回 `false` 时会在超时内重复调用,这是需要修正的现有问题。
## 2. 简单扩展 **[提案]**
BACK 保持“单次系统返回”,只增加可选前后条件:
~~~json
{
"id": "return-to-list",
"action": "BACK",
"packageName": "com.example.target",
"before": {
"state": "VISIBLE",
"selector": {
"text": "详情页面"
}
},
"after": {
"state": "VISIBLE",
"selector": {
"text": "列表页面"
}
},
"timeoutMs": 5000
}
~~~
关闭页面内按钮使用 CLICK;HOME、RECENTS 等其他系统导航不并入 BACK。关闭输入法如果需要,可以在以后增加明确参数,不在当前动作中猜测意图。
## 3. 执行规则
1. 在总超时内满足包名、Activity 和 before。
2. 最多调用一次 `GLOBAL_ACTION_BACK`。
3. 调用返回 false 时立即失败。
4. 丢弃旧页面节点。
5. 提供 after 时等待新页面满足条件。
after 超时不会自动再次返回。连续返回需要编写多个 BACK 步骤,每一步都可以声明自己的页面条件。
## 4. 结果码
- `BACK_SENT`:系统接受返回请求,未声明 after。
- `OK`:返回后 after 满足。
- `PRECONDITION_FAILED`
- `ACTION_FAILED`
- `VERIFICATION_FAILED`
## 5. 测试
覆盖前置页面不符、调用成功、调用失败、单次分发、after 成功/超时和多个显式 BACK 步骤。