9 lines
670 B
TypeScript
9 lines
670 B
TypeScript
import { createDriver } from '../drivers/factory';
|
|
const sleep=(ms:number)=>new Promise(r=>setTimeout(r,ms));
|
|
(async()=>{const d=createDriver();await d.createSession();try{
|
|
await d.dismissPopupIfPresent();await d.goBackToHomepage();await sleep(1000);
|
|
const names=new Set<string>();
|
|
for(let i=0;i<8;i++){const s=await d.getSource();for(const m of s.matchAll(/text="([^"]+)"/g)){const t=m[1];if(/S10|Robot|Floor|Vacuum|扫地/i.test(t))names.add(t);} await d.swipe(540,1500,540,700,0.4).catch(()=>{});await sleep(700);}
|
|
console.log('ROBOT_CARDS='+JSON.stringify([...names]));
|
|
}catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();
|