修 iOS 选品类点空:屏外元素先滚进可视区再点 + 校验真进流程
根因:WDA 返回屏外元素(品类常在 y=1192,屏高 844),旧代码直接点屏外坐标→点空没导航却 return true→relay 在目录页空按→添加失败("没点进入口")。
修复:① selectDeviceCategory 找到品类后先滚动送进可视区(y∈[0.10h,0.82h])再点,在下方下滑/上方上滑;② 点后用 "Add Manually"(目录页独有)是否消失校验真进流程,替代会误判的 includes(categoryName)。
验证:Robot Vacuum Cleaner S1 Plus 现可正确进入 Configuration wizard。
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
cf153b31ab
commit
85a6f04fb1
|
|
@ -149,6 +149,10 @@ export async function selectDeviceCategory(driver: DeviceDriver, categoryName: s
|
|||
await driver.swipe(Math.round(catW / 2), Math.round(catH * 0.60), Math.round(catW / 2), Math.round(catH * 0.38), 0.4);
|
||||
await sleep(650); // 等动量沉降稳定再 find(短等待会在列表还在动时查 → 漏)
|
||||
};
|
||||
const slowScrollUp = async () => {
|
||||
await driver.swipe(Math.round(catW / 2), Math.round(catH * 0.38), Math.round(catW / 2), Math.round(catH * 0.60), 0.4);
|
||||
await sleep(650);
|
||||
};
|
||||
const iosFind = async (): Promise<string | null> => {
|
||||
// 一条 predicate 覆盖 StaticText/Other/通用(name 或 label)。⚠️ 用**大小写不敏感** `==[c]`:
|
||||
// iOS 品类名是 Title Case(如 "RGBIC Neon Wire Rope Light"),用例常写小写 → 敏感匹配会"滚到底也找不到入口"。
|
||||
|
|
@ -168,27 +172,32 @@ export async function selectDeviceCategory(driver: DeviceDriver, categoryName: s
|
|||
if (scrollHint > 1 && !(await iosFind())) {
|
||||
for (let i = 0; i < scrollHint - 1; i++) { await slowScroll(); }
|
||||
}
|
||||
for (let i = 0; i < 16; i++) {
|
||||
let el = await iosFind();
|
||||
for (let i = 0; i < 24; i++) {
|
||||
const el = await iosFind();
|
||||
if (el) {
|
||||
const visible = await driver.getElementAttribute(el, 'visible').catch(() => 'true');
|
||||
if (String(visible) !== 'true' && String(visible) !== '1') {
|
||||
await slowScroll();
|
||||
const rect = await driver.getElementRect(el).catch(() => null);
|
||||
if (rect && rect.width > 0) {
|
||||
// ★ WDA 会返回**屏外元素**(实测品类常在 y=1192,屏高仅 844)→ 直接点屏外坐标无效="点了没进流程"。
|
||||
// 必须先把它**滚进可视区**(y 在 [0.10h, 0.82h])再点:在下方就下滑、在上方就上滑。
|
||||
if (rect.y < catH * 0.10 || rect.y + rect.height > catH * 0.82) {
|
||||
if (rect.y > catH * 0.5) await slowScroll(); else await slowScrollUp();
|
||||
continue;
|
||||
}
|
||||
await driver.tapElement(el); await sleep(2500);
|
||||
// ★ 校验真进了流程:**"Add Manually" 是 Add Device 目录页独有标志**,消失=已离开目录进流程
|
||||
// (不能用 includes(categoryName):目录页本就列着品类名 → 误判成功)。
|
||||
const after = await driver.getSource();
|
||||
const entered = !/Add Manually|Scanning for Bluetooth/i.test(after)
|
||||
|| /Next|Connect|Configuration|wizard|Before Using|press the button|hold the button|Disclaimer|配对|连接|下一步/i.test(after);
|
||||
if (entered) return true;
|
||||
console.log(`点 ${categoryName} 后仍在目录页(疑点空),重试`);
|
||||
await sleep(500);
|
||||
continue;
|
||||
}
|
||||
// 防贴底误点:卡片太靠下(y>700/844,易被底部栏挡或点到边缘)→ 先小幅上滑抬起,重取再点
|
||||
const rect = await driver.getElementRect(el).catch(() => null);
|
||||
if (rect && rect.y > 700) {
|
||||
await slowScroll();
|
||||
const el2 = await iosFind(); if (el2) el = el2;
|
||||
}
|
||||
await driver.tapElement(el); // 真实坐标 tap(比 /click 稳)
|
||||
await sleep(3000);
|
||||
return true;
|
||||
}
|
||||
await slowScroll();
|
||||
}
|
||||
console.log(`FAIL: no ${categoryName} option`);
|
||||
console.log(`FAIL: no ${categoryName} option(或点击未进入流程)`);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue