import { chromium } from 'playwright'; async function run() { const browser = await chromium.launch({ executablePath: 'C:/Users/12914/AppData/Local/ms-playwright/chromium-1234/chrome-win64/chrome.exe', headless: true, }); const page = await browser.newPage({ viewport: { width: 420, height: 900 } }); console.log('Navigating to editor...'); await page.goto('http://127.0.0.1:5173/#/pages/editor/editor', { waitUntil: 'networkidle' }); await page.waitForTimeout(1000); // 1. 截取主编辑器(包含大标题样式按钮、开头插入条等) await page.screenshot({ path: 'editor_meipian_main.png' }); console.log('Main editor shot saved'); // 2. 点击进入美篇预览 const previewBtn = page.locator('.nav-btn-preview'); if (await previewBtn.count() > 0) { await previewBtn.click(); await page.waitForTimeout(800); await page.screenshot({ path: 'editor_meipian_preview.png' }); console.log('Preview overlay shot saved'); // 3. 点击模板 Tab const templateTab = page.locator('.mp-dock-tab').first(); if (await templateTab.count() > 0) { await templateTab.click(); await page.waitForTimeout(600); await page.screenshot({ path: 'editor_meipian_template_dock.png' }); console.log('Template dock shot saved'); } } await browser.close(); console.log('All shots finished successfully'); } run().catch((e) => { console.error(e); process.exit(1); });