Files
novalon-website/e2e/src/tests/debug/contact-all-elements.spec.ts
T
张翔 5d5b7feb0a feat(e2e): 添加完整的E2E测试框架和测试用例
添加Playwright测试框架配置和基础页面对象
实现冒烟测试用例覆盖首页和联系页面核心功能
更新导航组件以支持滚动高亮功能
添加BackButton组件统一返回按钮行为
配置Woodpecker CI集成和测试报告生成
2026-02-27 10:30:33 +08:00

57 lines
2.4 KiB
TypeScript

import { test, expect } from '@playwright/test';
test('检查联系页面所有元素', async ({ page }) => {
await page.goto('/contact');
await page.waitForLoadState('networkidle');
const badges = await page.locator('[class*="badge"]').all();
console.log('找到的badge数量:', badges.length);
for (let i = 0; i < badges.length; i++) {
const badge = badges[i];
const className = await badge.evaluate(el => el.className);
const text = await badge.textContent();
console.log(`Badge ${i}: ${className} - ${text}`);
}
const contactCard = page.locator('[class*="card"]').filter({ hasText: '联系方式' }).first();
const contactCardText = await contactCard.textContent();
console.log('联系卡片文本:', contactCardText?.substring(0, 100));
const workHoursCard = page.locator('[class*="card"]').filter({ hasText: '工作时间' }).first();
const workHoursCardText = await workHoursCard.textContent();
console.log('工作时间卡片文本:', workHoursCardText?.substring(0, 100));
const addressH3 = contactCard.locator('h3:has-text("公司地址")');
const addressParent = addressH3.locator('..');
const addressGrandParent = addressParent.locator('..');
const addressP = addressGrandParent.locator('p');
const addressText = await addressP.textContent();
console.log('地址文本:', addressText);
const phoneH3 = contactCard.locator('h3:has-text("联系电话")');
const phoneParent = phoneH3.locator('..');
const phoneGrandParent = phoneParent.locator('..');
const phoneP = phoneGrandParent.locator('p');
const phoneText = await phoneP.textContent();
console.log('电话文本:', phoneText);
const emailH3 = contactCard.locator('h3:has-text("电子邮箱")');
const emailParent = emailH3.locator('..');
const emailGrandParent = emailParent.locator('..');
const emailP = emailGrandParent.locator('p');
const emailText = await emailP.textContent();
console.log('邮箱文本:', emailText);
const workHoursRows = workHoursCard.locator('.space-y-2 > div');
const workHoursCount = await workHoursRows.count();
console.log('工作时间行数:', workHoursCount);
for (let i = 0; i < workHoursCount; i++) {
const row = workHoursRows.nth(i);
const day = await row.locator('span').first().textContent();
const hours = await row.locator('span').nth(1).textContent();
console.log(`工作时间 ${i}: ${day} - ${hours}`);
}
});