Files

85 lines
2.2 KiB
Markdown
Raw Permalink 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.
# CLICK
> [返回动作目录](README.md) · [任务协议](../protocol.md) · [统一选择器](../selector.md) · [执行与结果](../execution.md)
## 1. 当前行为 **[部分实现]**
~~~json
{
"id": "click-continue",
"action": "CLICK",
"packageName": "com.example.target",
"selector": {
"resourceId": "com.example.target:id/continue_button"
},
"timeoutMs": 5000
}
~~~
当前实现:
- 等待 selector 匹配唯一节点。
- 节点自身不可点击时,向上查找最近的可点击祖先。
- 调用 `ACTION_CLICK`。
- 不检查可见、启用和有效边界。
- 不验证点击后的页面。
- 驱动返回 `false` 时会再次查询并重复点击,这是需要修正的现有问题。
## 2. 简单扩展 **[提案]**
~~~json
{
"id": "click-submit",
"action": "CLICK",
"packageName": "com.example.target",
"selector": {
"text": {
"mode": "CONTAINS_ANY",
"values": ["提交", "确认"]
},
"state": {
"visible": true,
"enabled": true
}
},
"click": {
"type": "SINGLE",
"method": "AUTO"
},
"after": {
"state": "VISIBLE",
"selector": {
"text": "操作完成"
}
},
"timeoutMs": 5000
}
~~~
首批只需要:
- `type`:`SINGLE`、`LONG`。
- `method`:`ACCESSIBILITY`、`CENTER_GESTURE`、`AUTO`。
- 默认目标必须唯一。
- `AUTO` 先使用节点动作;只有目标已唯一确认且边界有效时,才使用中心手势兜底。
位置排序、重叠候选归并等复杂策略按实际页面需要再增加。
## 3. 执行规则
1. 等待包名、可选 Activity 和唯一可交互目标。
2. 解析最近的可点击祖先。
3. 最多分发一次点击。
4. 丢弃旧节点。
5. 提供 after 时读取新页面并验证;未提供时只表示点击请求成功。
## 4. 结果码
见[结果码总表](README.md#结果码总表)。CLICK 使用 `OK`、`TARGET_NOT_FOUND`、`TARGET_AMBIGUOUS`、`TARGET_NOT_INTERACTABLE`、`ACTION_FAILED` 和 `VERIFICATION_FAILED`。
未声明 after 时,成功只表示点击已分发,不表示页面已变化。
## 5. 测试
覆盖节点点击、可点击祖先、多个目标、不可见/禁用、手势兜底、单次分发和 after 成功/超时。