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{ const del=await d.findElementRaw('-android uiautomator','new UiSelector().text("Delete")').catch(()=>null); if(del){await d.tapElement(del);await sleep(2000);console.log('点Delete后: '+JSON.stringify(await dump(d))); // 确认框 for(const t of ['Delete','Confirm','OK','确定','Yes']){const b=await d.findElementRaw('-android uiautomator',`new UiSelector().text("${t}")`).catch(()=>null);if(b){await d.tapElement(b);await sleep(2500);console.log(`确认(${t})后: `+JSON.stringify(await dump(d)));break;}} } else console.log('无Delete, 当前: '+JSON.stringify(await dump(d))); }catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();