Files
vscode-workbench/login-templates/v3-mobile/_verify_v2.js
T

57 lines
2.1 KiB
JavaScript

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(800);
// 1. 默认密码登录
await page.screenshot({ path: path.join(out, 't4-v2-pwd.png'), fullPage: true });
console.log('OK: t4-v2-pwd.png');
// 2. 切到验证码登录 - 默认手机
await page.click('text=验证码登录');
await page.waitForTimeout(400);
await page.screenshot({ path: path.join(out, 't4-v2-code-phone.png'), fullPage: true });
console.log('OK: t4-v2-code-phone.png');
// 3. 切到邮箱
await page.click('.vs-toggle >> text=邮箱');
await page.waitForTimeout(400);
await page.screenshot({ path: path.join(out, 't4-v2-code-email.png'), fullPage: true });
console.log('OK: t4-v2-code-email.png');
// 4. 注册页
await page.click('text=立即注册');
await page.waitForTimeout(400);
await page.screenshot({ path: path.join(out, 't4-v2-reg.png'), fullPage: true });
console.log('OK: t4-v2-reg.png');
// 5. 找回密码
await page.click('text=去登录');
await page.waitForTimeout(400);
await page.click('text=密码登录');
await page.waitForTimeout(300);
await page.click('text=忘记密码?');
await page.waitForTimeout(400);
await page.screenshot({ path: path.join(out, 't4-v2-forgot.png'), fullPage: true });
console.log('OK: t4-v2-forgot.png');
await browser.close();
console.log('All done!');
})();