feat(M2): 语义层工具 de_ui_tree/de_tap_element——UI 树元素定位点击(text/id/desc,多命中 index),无需坐标更可靠;坐标 tap 保留兜底(WebView/画布元素)
This commit is contained in:
@@ -107,6 +107,19 @@ class PlatformClient:
|
||||
"duration": float(duration)})
|
||||
return self._check_op(r, "swipe")
|
||||
|
||||
def ui_elements(self, serial):
|
||||
"""UI 元素树(GET /api/uiauto/elements,uiautodev 服务)。"""
|
||||
r = self._get("/api/uiauto/elements", serial=serial)
|
||||
if r.status_code == 503:
|
||||
raise PlatformError("device_offline", r.text[:120])
|
||||
if r.status_code != 200:
|
||||
raise PlatformError("platform_unavailable",
|
||||
f"元素树 HTTP {r.status_code}")
|
||||
j = r.json() or {}
|
||||
if not j.get("ok"):
|
||||
raise PlatformError("device_offline", str(j.get("error", "取元素失败"))[:120])
|
||||
return j.get("elements", [])
|
||||
|
||||
def wake(self, serial):
|
||||
"""亮屏并解锁(POST /api/device/screen_all mode=on)。"""
|
||||
r = self._post("/api/device/screen_all",
|
||||
|
||||
Reference in New Issue
Block a user