8 lines
793 B
TypeScript
8 lines
793 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))].slice(0,18) as string[];
|
|
(async()=>{const d=createDriver();await d.createSession();try{
|
|
for(const t of ['Configure network','Configure Network','Next','Configure']){const b=await d.findElementRaw('-android uiautomator',`new UiSelector().text("${t}")`).catch(()=>null);if(b){await d.tapElement(b);console.log('点了 '+t);break;}}
|
|
await sleep(3500);console.log('下一页: '+JSON.stringify(await dump(d)));
|
|
}catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();
|