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}`); } });