const { chromium } = require('playwright-core'); (async () => { const CHROME = String.raw`C:\Program Files\Google\Chrome\Application\chrome.exe`; const browser = await chromium.launch({ executablePath: CHROME, headless: true }); const page = await browser.newPage({ viewport: { width: 1366, height: 850 } }); const errs = []; page.on('pageerror', e => errs.push(e.message)); const base = 'http://127.0.0.1:8010'; const r = await fetch(base + '/api/auth/login', { method:'POST', headers:{'Content-Type':'application/json'}, body: JSON.stringify({phone:'13943441149',password:'Test1234'}) }); const tok = (await r.json()).access_token; await page.goto('http://127.0.0.1:5175/login'); await page.evaluate(t => { localStorage.setItem('access_token', t); localStorage.setItem('refresh_token','r'); }, tok); await page.goto('http://127.0.0.1:5175/exercise'); await page.waitForTimeout(2500); await page.locator('.tpl-btn').first().click(); await page.waitForTimeout(1500); await page.locator('.tg-search input').fill('成语接龙'); await page.waitForTimeout(800); await page.locator('.tg-card').first().click(); await page.waitForTimeout(2000); // type and play const frame = page.frameLocator('.tg-preview-wrap iframe').first(); await frame.locator('#inp').fill('一心一意'); await page.keyboard.press('Enter'); await page.waitForTimeout(2500); const chainCount = await frame.locator('#list > div').count().catch(()=>0); console.log('ERRORS:', errs.length, 'CHAIN_ITEMS:', chainCount); if (errs.length) console.log('ERR:', errs.slice(0,3)); await browser.close(); })();