const { chromium } = require("@playwright/test"); (async () => { const browser = await chromium.launch({ executablePath: "C:/Users/MoBai/AppData/Local/ms-playwright/chromium_headless_shell-1228/chrome-headless-shell-win64/chrome-headless-shell.exe", }); const page = await browser.newPage({ viewport: { width: 1200, height: 800 } }); await page.goto("http://localhost:5173/"); await page.waitForTimeout(1500); const hasLogin = await page.$('input[placeholder="请输入工号"]'); if (hasLogin) { await page.fill('input[placeholder="请输入工号"]', "test001"); await page.fill('input[placeholder="请输入您的密码"]', "test123"); await page.click('button:has-text("登录")'); await page.waitForTimeout(15000); } else { await page.waitForTimeout(12000); } await page.click("text=测试二号"); await page.waitForTimeout(3000); // 「…」菜单 await page.click(".anticon-more"); await page.waitForTimeout(800); await page.screenshot({ path: "e2e/screenshots/06-header-menu.png" }); await page.keyboard.press("Escape"); await page.waitForTimeout(500); // 表情面板 await page.click(".anticon-smile"); await page.waitForTimeout(800); await page.screenshot({ path: "e2e/screenshots/07-emoji.png" }); await page.keyboard.press("Escape"); await browser.close(); console.log("done"); })().catch((e) => { console.error(e); process.exit(1); });