AI_UIAutomation/scripts/explore-lock.ts

25 lines
1.3 KiB
TypeScript

import * as dotenv from 'dotenv'; import * as path from 'path';
dotenv.config({ path: path.resolve(__dirname, '../.env') });
import { createDriver } from '../drivers/factory';
import { findHomeCard } from '../utils/common/device-settings.helper';
import { sleep } from '../utils/common/element.helper';
(async () => {
const d = createDriver(); await d.createSession();
await d.goBackToHomepage(); await sleep(800);
const el = await findHomeCard(d, process.env.LK || 'Lock 6D');
console.log('找到Lock卡:', !!el);
if (el) { await d.tapElement(el); await sleep(2500); }
// 点掉可能的引导框(Got it / About Home Sharing)
for (let i = 0; i < 3; i++) {
const g = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("Got it")').catch(() => null);
if (!g) break;
await d.tapElement(g); await sleep(1500); console.log('点了 Got it');
}
await sleep(1500);
const src = await d.getSource();
console.log('tvStatus存在:', /tvStatus/.test(src), '| lavAnimate存在:', /lavAnimate/.test(src));
console.log('疑似浮层:', /Action Panel|快捷|Lock\/Unlock|Press and/.test(src));
console.log('页面text:', [...new Set((src.match(/text="[^"]{2,24}"/g) || []))].slice(0, 18).join(' '));
await d.destroySession();
})().catch(e => { console.error('ERR', e.message); process.exit(1); });