24 lines
1.5 KiB
TypeScript
24 lines
1.5 KiB
TypeScript
import * as dotenv from 'dotenv'; import * as path from 'path';
|
|
dotenv.config({ path: path.resolve(__dirname, '../.env') });
|
|
import { createDriver } from '../drivers/factory';
|
|
import { findHomeCard } from '../utils/common/device-settings.helper';
|
|
import { sleep } from '../utils/common/element.helper';
|
|
(async () => {
|
|
const d = createDriver(); await d.createSession();
|
|
await d.goBackToHomepage(); await sleep(800);
|
|
const el = await findHomeCard(d, process.env.BT || 'Blind Tilt 42');
|
|
if (el) { await d.tapElement(el); await sleep(2000); }
|
|
const more = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("More")').catch(() => null);
|
|
if (more) { await d.tapElement(more); await sleep(2500); }
|
|
for (let i = 0; i < 3; i++) { const g = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("Got it")').catch(() => null); if (!g) break; await d.tapElement(g); await sleep(1000); }
|
|
for (let i = 0; i < 8; i++) { const s = await d.getSource(); if (!/Connecting to your device/.test(s)) break; await sleep(2000); }
|
|
const src = await d.getSource();
|
|
const rows = [...src.matchAll(/text="([^"]+)"[^>]*bounds="\[(\d+),(\d+)\]\[(\d+),(\d+)\]"/g)]
|
|
.map(m => ({ t: m[1], x: +m[2], y: +m[3] }))
|
|
.filter(r => r.t.length >= 2)
|
|
.sort((a, b) => a.y - b.y);
|
|
console.log('功能页所有文字(按 y 从上到下):');
|
|
for (const r of rows.slice(0, 25)) console.log(` y=${String(r.y).padStart(4)} x=${String(r.x).padStart(4)} "${r.t}"`);
|
|
await d.destroySession();
|
|
})().catch(e => { console.error('ERR', e.message); process.exit(1); });
|