import { test, expect } from '@playwright/test'; test('检查联系页面详细元素', async ({ page }) => { await page.goto('/contact'); await page.waitForLoadState('networkidle'); const pageHeader = page.locator('h1:has-text("与我们取得联系")'); const pageHeaderParent = pageHeader.locator('..'); const pageHeaderGrandParent = pageHeaderParent.locator('..'); console.log('Page Header parent:', await pageHeaderParent.evaluate(el => el.className)); console.log('Page Header grand parent:', await pageHeaderGrandParent.evaluate(el => el.className)); const badges = await pageHeaderGrandParent.locator('.badge').all(); console.log('找到的badge数量:', badges.length); for (let i = 0; i < badges.length; i++) { const badge = badges[i]; const text = await badge.textContent(); console.log(`Badge ${i}: ${text}`); } const contactCard = page.locator('h3:has-text("联系方式")'); const contactCardParent = contactCard.locator('..'); const contactCardGrandParent = contactCardParent.locator('..'); const contactCardGreatGrandParent = contactCardGrandParent.locator('..'); console.log('Contact card great grand parent:', await contactCardGreatGrandParent.evaluate(el => el.className)); const addressElement = contactCard.locator('text=公司地址').locator('..').locator('p'); const addressText = await addressElement.textContent(); console.log('地址:', addressText); const phoneElement = contactCard.locator('text=联系电话').locator('..').locator('p'); const phoneText = await phoneElement.textContent(); console.log('电话:', phoneText); const emailElement = contactCard.locator('text=电子邮箱').locator('..').locator('p'); const emailText = await emailElement.textContent(); console.log('邮箱:', emailText); });