Files
hms/apps/miniprogram/test-debug.cjs
iven 50eae8b809 feat(miniprogram): 温润东方风全面 UI 重设计
73 文件变更,覆盖全部 40 个页面 SCSS + TabBar 图标 + 组件样式。
统一赤陶主色 #C4623A + 暖米背景 + 衬线标题字体 + 12px 圆角体系。
2026-04-28 00:19:52 +08:00

51 lines
1.7 KiB
JavaScript

const automator = require('miniprogram-automator');
(async () => {
console.log('连接...');
const mp = await automator.connect({ wsEndpoint: 'ws://127.0.0.1:9420' });
await mp.switchTab('/pages/index/index');
await new Promise(r => setTimeout(r, 5000));
const page = await mp.currentPage();
console.log('page:', page.path);
// Test 1: Get all views
console.log('\n--- Test 1: All views ---');
const allViews = await page.$$('view');
console.log('view count:', allViews.length);
// Test 2: Get text from first 20 views
for (let i = 0; i < Math.min(allViews.length, 20); i++) {
try {
const text = (await allViews[i].textContent()).trim().replace(/\s+/g, ' ');
if (text.length > 0) console.log(' view[' + i + ']:', text.substring(0, 60));
} catch {}
}
// Test 3: Get all text elements
console.log('\n--- Test 2: All text ---');
const allTexts = await page.$$('text');
console.log('text count:', allTexts.length);
for (let i = 0; i < Math.min(allTexts.length, 30); i++) {
try {
const text = (await allTexts[i].textContent()).trim();
if (text.length > 0) console.log(' text[' + i + ']:', text.substring(0, 60));
} catch {}
}
// Test 4: Try waitFor
console.log('\n--- Test 3: waitFor ---');
try {
await page.waitFor('.index-page', { timeout: 3000 });
console.log('.index-page: found');
} catch (e) {
console.log('.index-page:', e.message);
}
// Test 5: Try getElementByXpath or other methods
console.log('\n--- Test 4: Page data ---');
const data = await page.data();
console.log('data:', JSON.stringify(data).substring(0, 300));
mp.disconnect();
})().catch(e => console.error('Error:', e.message));