import { createDriver } from '../drivers/factory'; (async () => { const d = createDriver(); await d.createSession(); try { const src = await d.getSource(); const texts = [...new Set(Array.from(src.matchAll(/text="([^"]+)"/g)).map((m) => m[1]).filter((t) => t.trim()))]; console.log('当前页文案=' + JSON.stringify(texts)); // clickable 节点的 text/desc const clk = Array.from(src.matchAll(/<[^>]*?(?:text="([^"]*)")?[^>]*?(?:content-desc="([^"]*)")?[^>]*?clickable="true"[^>]*?>/g)) .map((m) => `${m[1] || ''}|${m[2] || ''}`).filter((s) => s !== '|'); console.log('可点按钮=' + JSON.stringify([...new Set(clk)].slice(0, 25))); } catch (e: any) { console.error('FAIL:', e.message); } finally { await d.destroySession(); } })();