// 期2 图片趴三类走查:资产库三类 tab(归类) + 图片生成页模特选择器接模特库 + 抓 console/pageerror。 import { chromium } from "playwright"; import fs from "node:fs"; import path from "node:path"; const BASE = process.env.BASE || "http://localhost:5188"; const OUT = path.resolve("../../../_qa_shots/models-p2"); fs.mkdirSync(OUT, { recursive: true }); const browser = await chromium.launch({ headless: true }); const r = { consoleErrors: [], library: {}, picker: {} }; const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 } }); const p = await ctx.newPage(); p.on("console", (m) => { if (m.type() === "error") r.consoleErrors.push(m.text()); }); p.on("pageerror", (e) => r.consoleErrors.push("PAGEERR:" + e.message)); // 登录 await p.goto(BASE + "/login", { waitUntil: "load" }); await p.waitForTimeout(400); await p.fill("#auth-username", "airshelf"); await p.fill("#auth-pwd", "Restraint2026"); await p.click("button.btn-cta"); await p.waitForFunction(() => !location.pathname.startsWith("/login"), { timeout: 12000 }); // ── 资产库:三类 tab 存在 + 计数 + 逐 tab 截图 ── await p.goto(BASE + "/library", { waitUntil: "load" }); await p.waitForTimeout(2600); for (const key of ["tryon", "kits", "creations"]) { r.library[key + "_tabExists"] = await p.locator(`.tab[data-tab="${key}"]`).count(); } async function openTab(key) { await p.locator(`.tab[data-tab="${key}"]`).click(); await p.waitForTimeout(2200); const cards = await p.locator(".asset-card, .lib-card, .ph-frame, .a-card").count(); await p.screenshot({ path: path.join(OUT, `library-${key}.png`), fullPage: true }); return cards; } r.library.tryonCards = await openTab("tryon"); r.library.kitsCards = await openTab("kits"); r.library.creationsCards = await openTab("creations"); // ── 图片生成页:模特上身图 → 模特选择器接模特库 ── await p.goto(BASE + "/model-photo", { waitUntil: "load" }); await p.waitForTimeout(2600); r.picker.url = p.url(); r.picker.modelCards = await p.locator(".model-grid .model-card").count(); r.picker.firstModelName = await p.locator(".model-grid .model-card .m-name").first().innerText().catch(() => ""); await p.screenshot({ path: path.join(OUT, "model-photo-picker.png"), fullPage: true }); await browser.close(); console.log(JSON.stringify(r, null, 2)); fs.writeFileSync(path.join(OUT, "summary.json"), JSON.stringify(r, null, 2));