10 lines
784 B
TypeScript
10 lines
784 B
TypeScript
import { createDriver } from '../drivers/factory';
|
|
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<40))].slice(0,25) as string[];
|
|
(async()=>{const d=createDriver();await d.createSession();try{
|
|
console.log('当前页文案: '+JSON.stringify(await dump(d)));
|
|
const src=await d.getSource();
|
|
// EditText 节点 + bounds + 旁边的提示文字
|
|
const eds=Array.from(src.matchAll(/<[^>]*class="android\.widget\.EditText"[^>]*bounds="(\[\d+,\d+\]\[\d+,\d+\])"[^>]*>/g)).map((m:any)=>m[1]);
|
|
console.log('EditText 数='+eds.length+' bounds='+JSON.stringify(eds));
|
|
}catch(e:any){console.error('FAIL:',e.message);}finally{await d.destroySession();}})();
|