| 123456789101112131415161718 |
- import { readFile } from 'node:fs/promises';
- import { chromium } from 'playwright';
- import { checkCustomer } from './customer-functional.mjs';
- const accounts = JSON.parse(await readFile(new URL('../../.work/frontend-accounts.json', import.meta.url), 'utf8'));
- const browser = await chromium.launch({ executablePath: process.env.PLAYWRIGHT_CHROMIUM_EXECUTABLE || 'C:/Users/Administrator/AppData/Local/ms-playwright/chromium-1228/chrome-win64/chrome.exe', headless: true });
- const page = await browser.newPage({ viewport: { width: 390, height: 844 } });
- page.setDefaultTimeout(15000);
- page.on('pageerror', error => console.error('浏览器错误:', error.message));
- page.on('response', async response => { if (response.status() >= 400) console.error('HTTP', response.status(), new URL(response.url()).pathname, await response.text()); });
- try {
- const results = await checkCustomer(page, process.env.FRONTEND_URL || 'http://127.0.0.1:18762', accounts);
- console.log(JSON.stringify({ passed: results }, null, 2));
- } catch (error) {
- console.error('当前页面:', page.url());
- console.error(await page.locator('body').innerText());
- throw error;
- } finally { await browser.close(); }
|