import { test } from '@playwright/test'; // 只打印、不判定:把「fixture browserName 值」与「真实引擎(userAgent)」两件事分开测, // 因为跳过条件读的是前者,而能力(Touchscreen API)取决于后者。 test('probe browserName identity', async ({ browserName, page }, testInfo) => { const ua = await page.evaluate(() => navigator.userAgent); const touchPoints = await page.evaluate(() => 'ontouchstart' in window ? (navigator.maxTouchPoints ?? 0) : -1); console.log( JSON.stringify({ project: testInfo.project.name, fixtureBrowserName: browserName, useBrowserName: (testInfo.project.use as { browserName?: string }).browserName ?? null, skipConditionIsTrue: browserName !== 'chromium', ua: ua.slice(0, 90), engine: /AppleWebKit\/.*Version\//.test(ua) && !/Chrome\//.test(ua) ? 'webkit' : /Firefox\//.test(ua) ? 'firefox' : /Chrome\//.test(ua) ? 'chromium' : 'unknown', touchPoints, }), ); });