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

55 lines
1.8 KiB
JavaScript

const automator = require('miniprogram-automator');
(async () => {
const mp = await automator.connect({ wsEndpoint: 'ws://127.0.0.1:9420' });
await mp.switchTab('/pages/index/index');
await new Promise(r => setTimeout(r, 2000));
const page = await mp.currentPage();
// Try $ selector (single element)
const title = await page.$('.section-title');
console.log('title element:', title ? 'found' : 'not found');
if (title) {
const text = await title.textContent();
console.log('title text:', text.trim());
}
// Try $$ selector (multiple)
const titles = await page.$$('.section-title');
console.log('titles count:', titles.length);
for (let i = 0; i < titles.length; i++) {
const text = await titles[i].textContent();
console.log(' title[' + i + ']:', text.trim());
}
// Check greeting
const hello = await page.$('.greeting-hello');
if (hello) console.log('greeting:', (await hello.textContent()).trim());
const name = await page.$('.greeting-name');
if (name) console.log('name:', (await name.textContent()).trim());
// Health items
const healthItems = await page.$$('.health-item');
console.log('health items:', healthItems.length);
for (let i = 0; i < healthItems.length; i++) {
const text = await healthItems[i].textContent();
console.log(' health[' + i + ']:', text.trim().replace(/\s+/g, ' '));
}
// Service items
const services = await page.$$('.service-item');
console.log('service items:', services.length);
for (let i = 0; i < services.length; i++) {
const text = await services[i].textContent();
console.log(' service[' + i + ']:', text.trim().replace(/\s+/g, ' '));
}
// Check empty state
const empty = await page.$('.empty-text');
if (empty) console.log('empty text:', (await empty.textContent()).trim());
await mp.close();
process.exit(0);
})()