AI_UIAutomation/scripts/probe-pc3.ts

12 lines
922 B
TypeScript

import { createDriver } from '../drivers/factory';
const sleep=(ms:number)=>new Promise(r=>setTimeout(r,ms));
const dump=async(d:any):Promise<string[]>=>[...new Set((Array.from((await d.getSource()).matchAll(/text="([^"]+)"/g)) as any[]).map(m=>m[1]).filter((t:string)=>t.trim()&&t.length<30))] as string[];
const clkOf=async(d:any):Promise<string[]>=>Array.from((await d.getSource()).matchAll(/clickable="true"[^>]*?bounds="(\[\d+,\d+\]\[\d+,\d+\])"/g)).map((m:any)=>m[1]);
(async()=>{const d=createDriver();await d.createSession();try{
console.log('当前页: '+JSON.stringify(await dump(d)));
// 点 Passcode 图标(左列 ~195,909)
await d.tap(195,909);await sleep(2500);
console.log('点Passcode图标后: '+JSON.stringify(await dump(d)));
console.log('该页clickable: '+JSON.stringify((await clkOf(d)).slice(0,15)));
}catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();