16 lines
1001 B
TypeScript
16 lines
1001 B
TypeScript
import { createDriver } from '../drivers/factory';
|
|
const sleep = (ms: number) => new Promise((r) => setTimeout(r, ms));
|
|
(async () => {
|
|
const d = createDriver();
|
|
await d.createSession();
|
|
try {
|
|
const dev = await d.findElementRaw('-android uiautomator', 'new UiSelector().textMatches("(?i)Relay Switch 1.*")').catch(() => null);
|
|
if (dev) { await d.tapElement(dev); console.log('已选设备'); await sleep(1500); } else console.log('未找到设备项');
|
|
const n = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("Next")').catch(() => null);
|
|
if (n) { await d.tapElement(n); console.log('已点 Next'); await sleep(3000); } else console.log('未找到 Next');
|
|
const texts = [...new Set(Array.from((await d.getSource()).matchAll(/text="([^"]+)"/g)).map((m) => m[1]).filter((t) => t.trim()))];
|
|
console.log('下一页文案=' + JSON.stringify(texts));
|
|
} catch (e: any) { console.error('FAIL:', e.message); }
|
|
finally { await d.destroySession(); }
|
|
})();
|