AI_UIAutomation/scripts/probe-s10-finish.ts

14 lines
928 B
TypeScript

import { createDriver } from '../drivers/factory';
import { configureHubWifi } from '../utils/common/hub.helper';
import { getWifiCredentials } from '../config/wifi.config';
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))].slice(0,20) as string[];
(async()=>{const d=createDriver();await d.createSession();try{
console.log('起始: '+JSON.stringify(await dump(d)));
await configureHubWifi(d, getWifiCredentials());
await sleep(3000);
await d.goBackToHomepage().catch(()=>{}); await sleep(2000);
const home=await dump(d);
console.log('首页含S10/Robot: '+JSON.stringify(home.filter(t=>/S10|Robot|Floor Cleaning|扫地/i.test(t))));
}catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();