35 lines
2.1 KiB
TypeScript
35 lines
2.1 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.CT || 'Curtain Auto');
|
|
console.log('找到Curtain卡:', !!el);
|
|
if (el) { await d.tapElement(el); 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(1200); console.log('点掉 Got it');
|
|
}
|
|
await sleep(1000);
|
|
// 点 More 进完整功能页
|
|
const more = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("More")').catch(() => null);
|
|
if (more) { await d.tapElement(more); await sleep(2500); console.log('点了 More 进功能页'); }
|
|
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(1200); console.log('功能页点掉 Got it');
|
|
}
|
|
await sleep(1000);
|
|
const src = await d.getSource();
|
|
const hasOpen = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("Open")').catch(() => null);
|
|
const hasClose = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("Close")').catch(() => null);
|
|
const hasPause = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("Pause")').catch(() => null);
|
|
const hasMore = await d.findElementRaw('-android uiautomator', 'new UiSelector().text("More")').catch(() => null);
|
|
console.log(`Open=${!!hasOpen} Close=${!!hasClose} Pause=${!!hasPause} More=${!!hasMore}`);
|
|
console.log('页面text:', [...new Set((src.match(/text="[^"]{2,28}"/g) || []))].slice(0, 20).join(' '));
|
|
await d.destroySession();
|
|
})().catch(e => { console.error('ERR', e.message); process.exit(1); });
|