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<30))] 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 文字 rect const pc=await d.findElementRaw('-android uiautomator','new UiSelector().text("Passcode")').catch(()=>null); if(pc){const pr=await d.getElementRect(pc);console.log(`Passcode rect=(${pr.x},${pr.y}) ${pr.width}x${pr.height}`); // 点整行中部(往右挪,避开图标) await d.tap(540, pr.y+pr.height/2);await sleep(2500);console.log('点行中部后: '+JSON.stringify(await dump(d)));} // dump clickable 节点 bounds const src=await d.getSource(); const clk=Array.from(src.matchAll(/clickable="true"[^>]*?bounds="(\[\d+,\d+\]\[\d+,\d+\])"/g)).map(m=>m[1]); console.log('clickable: '+JSON.stringify(clk.slice(0,15))); }catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();