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(); page.on('pageerror', e => console.log('PAGEERROR:', e.message, '\nSTACK:', e.stack)); page.on('console', m => { if (m.type()==='error') console.log('CONSOLE_ERR:', m.text()); }); // Load the module and render probability template await page.goto('http://127.0.0.1:5175/animation'); // we need the template render output; use the gallery instead but isolate await page.waitForTimeout(1500); // inject token 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()).data?.access_token; await page.evaluate(t => { localStorage.setItem('access_token', t); localStorage.setItem('refresh_token','r'); }, tok); await page.goto('http://127.0.0.1:5175/animation'); await page.waitForTimeout(2000); // open gallery and jump directly to probability card await page.locator('.tpl-btn').first().click(); await page.waitForTimeout(1200); // search for probability await page.locator('.tg-search input').fill('概率'); await page.waitForTimeout(600); await page.locator('.tg-card').first().click(); await page.waitForTimeout(2000); console.log('done'); await browser.close(); })();