import { chromium } from "playwright"; import path from "node:path"; import fs from "node:fs"; const PID="53d7a7c3-2f41-431b-82d3-3acc97900310"; const OUT=path.resolve("../../../_qa_shots/pd"); fs.mkdirSync(OUT,{recursive:true}); const b=await chromium.launch({headless:true}); const r={consoleErrors:[]}; const p=await (await b.newContext({viewport:{width:1440,height:1000}})).newPage(); p.on("console",m=>{if(m.type()==="error")r.consoleErrors.push(m.text())}); p.on("pageerror",e=>r.consoleErrors.push("PE:"+e.message)); await p.goto("http://localhost:5200/login"); await p.waitForTimeout(300); 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}); await p.goto("http://localhost:5200/products/"+PID); await p.waitForTimeout(3000); r.roleCards=await p.locator(".pd-role-card").count(); r.roleFoot=await p.locator(".pd-role-card .pd-role-foot .mono").allInnerTexts().catch(()=>[]); r.packCards=await p.locator(".pd-pack-card").count(); r.flatCards=await p.locator(".pd-mat-grid .asset-card:not(.pd-role-card):not(.pd-pack-card)").count(); r.typePills=await p.locator(".pd-mat-grid .type-pill").allInnerTexts().catch(()=>[]); await p.screenshot({path:path.join(OUT,"pd-materials-v2.png"),fullPage:true}); // 点角色卡看弹窗 if(r.roleCards>0){await p.locator(".pd-role-card").first().click();await p.waitForTimeout(1000);r.roleModalItems=await p.locator(".pd-group-item").count();await p.screenshot({path:path.join(OUT,"pd-role-modal.png")});} await b.close(); console.log(JSON.stringify(r,null,2));