const pwPath = String.raw`C:\Users\12914\.cache\codex-runtimes\codex-primary-runtime\dependencies\node\node_modules\playwright-core`; const { chromium } = require(pwPath); const path = require('path'); const fs = require('fs'); const base = String.raw`C:\Users\12914\Desktop\vscode\login-templates\v3-mobile`; const out = path.join(base, 'screenshots'); if (!fs.existsSync(out)) fs.mkdirSync(out, {recursive: true}); const file = 'file:///' + path.join(base, 'template4-fullscreen-dark.html').replace(/\\/g, '/'); (async () => { const browser = await chromium.launch({ headless: true }); const ctx = await browser.newContext({ viewport: { width: 390, height: 844 }, deviceScaleFactor: 2, }); const page = await ctx.newPage(); await page.goto(file, { waitUntil: 'networkidle', timeout: 15000 }); await page.waitForTimeout(1000); // 6. 找回密码 - 切回密码登录tab再点击忘记密码 await page.click('text=密码登录'); await page.waitForTimeout(300); await page.click('text=忘记密码?'); await page.waitForTimeout(500); await page.screenshot({ path: path.join(out, 't4-forgot-method.png'), fullPage: true }); console.log('OK: t4-forgot-method.png'); // 7. 找回密码 - 手机方式表单 await page.click('text=通过手机找回'); await page.waitForTimeout(500); await page.screenshot({ path: path.join(out, 't4-forgot-phone.png'), fullPage: true }); console.log('OK: t4-forgot-phone.png'); // 8. 找回密码 - 邮箱方式 await page.click('text=返回选择方式'); await page.waitForTimeout(500); await page.click('text=通过邮箱找回'); await page.waitForTimeout(500); await page.screenshot({ path: path.join(out, 't4-forgot-email.png'), fullPage: true }); console.log('OK: t4-forgot-email.png'); // 9. 重置成功 await page.click('text=重置密码'); await page.waitForTimeout(500); await page.screenshot({ path: path.join(out, 't4-reset-success.png'), fullPage: true }); console.log('OK: t4-reset-success.png'); await browser.close(); console.log('All done!'); })();