← snapshot
1208 bytes
import { chromium } from "@playwright/test";
const b = await chromium.launch();
const p = await b.newPage({ viewport: { width: 1500, height: 1050 }, colorScheme: "dark" });
const errs = [];
p.on("pageerror", e => errs.push(e.message));
p.on("console", m => { if (m.type()==="error") errs.push(m.text()); });
await p.goto("http://localhost:3000/shelf", { waitUntil: "networkidle" });
await p.waitForSelector(".jac-shelf-list li", { timeout: 25000 });
await p.waitForTimeout(1200);
const info = await p.evaluate(() => ({
counts: document.querySelector(".jac-shelf-counts")?.innerText.replace(/\n/g," "),
legend: [...document.querySelectorAll(".jac-shelf-legend li")].map(x => x.innerText.replace(/\s+/g," ").trim()),
rows: document.querySelectorAll(".jac-shelf-list li").length,
top: [...document.querySelectorAll(".jac-shelf-list li")].slice(0,4).map(li =>
li.querySelector(".jac-shelf-name")?.textContent + " :: " + li.querySelector(".jac-shelf-nums")?.innerText.replace(/\n/g," ")),
}));
console.log(JSON.stringify(info, null, 2));
await p.screenshot({ path: "tour/lab/shelf.png", fullPage: true });
console.log("errors:", errs.length ? [...new Set(errs)].slice(0,3) : "none");
await b.close();