Files

39 lines
1.3 KiB
JavaScript

const automator = require('miniprogram-automator');
(async () => {
const mp = await automator.connect({ wsEndpoint: 'ws://localhost:9420' });
mp.on('console', msg => {
console.log(' [' + msg.type + ']', msg.args.join(' ').substring(0, 250));
});
// 用 reLaunch 干净进入编辑模式
const page = await mp.reLaunch('/pages/create-activity/index?mode=edit&id=8055ec9d-4d9e-4786-9f8e-f6938b595430');
await new Promise(r => setTimeout(r, 4000));
const data = await page.data();
console.log('mode:', data.mode);
console.log('form.title:', data.form?.title);
console.log('form.description:', data.form?.description?.substring(0, 40));
console.log('form.location:', data.form?.location);
// 找提交按钮
const allEls = await page.$$('button');
console.log('\n所有按钮:');
for (const el of allEls) {
const text = await el.text();
console.log(' "' + text + '"');
}
// 找导航栏的"使用模板"
const allViews = await page.$$('view');
let found = 0;
for (const v of allViews) {
if (found > 5) break;
const text = await v.text();
if (text.includes('模板') || text.includes('编辑') || text.includes('创建')) {
console.log(' view文本:', text.substring(0, 30));
found++;
}
}
await mp.close();
})();