import { createDriver } from '../drivers/factory'; const sleep=(ms:number)=>new Promise(r=>setTimeout(r,ms)); const dump=async(d:any):Promise=>[...new Set((Array.from((await d.getSource()).matchAll(/text="([^"]+)"/g)) as any[]).map(m=>m[1]).filter((t:string)=>t.trim()&&t.length<40))] as string[]; (async()=>{const d=createDriver();await d.createSession();try{ await d.dismissPopupIfPresent();await d.goBackToHomepage();await sleep(1000); let el=null;for(let i=0;i<8;i++){el=await d.findElementRaw('-android uiautomator','new UiSelector().textContains("Keypad Vision")').catch(()=>null);if(el)break;await d.swipe(540,1500,540,700,0.4).catch(()=>{});await sleep(700);} const r=await d.getElementRect(el!);await d.tap(r.x+100,r.y-20);await sleep(5000);await d.dismissPopupIfPresent();await sleep(1500); // Passcode tab const pc=await d.findElementRaw('-android uiautomator','new UiSelector().text("Passcode")').catch(()=>null); if(pc){const pr=await d.getElementRect(pc);await d.tap(Math.round(pr.x+pr.width/2),Math.round(pr.y+pr.height/2));await sleep(2000);} console.log('Passcode tab: '+JSON.stringify(await dump(d))); // 点密码项 "Permanent Passcode 1" const item=await d.findElementRaw('-android uiautomator','new UiSelector().textContains("Permanent Passcode")').catch(()=>null); if(item){await d.tapElement(item);await sleep(2500);console.log('点密码项后: '+JSON.stringify(await dump(d)));} else console.log('无密码项'); }catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();