← back to Lawyer Directory Builder
scripts/take-shots.mjs
44 lines
/**
* Capture full-page screenshots of every key URL in the lawyer directory.
* Output: public/qa-shots/*.png → served at http://localhost:9701/qa-shots/
*/
import { chromium } from 'playwright';
import fs from 'node:fs';
import path from 'node:path';
const OUT = path.resolve('public/qa-shots');
fs.mkdirSync(OUT, { recursive: true });
const BASE = 'http://localhost:9701';
const urls = [
['dashboard', '/dashboard.html'],
['mockups', '/mockups'],
['mockups-x-only', '/mockups?variant=x'],
['community', '/community'],
['firm-bodie-law', '/firms/4'],
['firm-large-sample', '/firms/26'],
['attorney-amos-lopez', '/attorneys/16692'],
['pitch-bodie', '/p/4'],
['marketing-landing', '/'],
['audit-viewer', '/audit.html'],
];
const browser = await chromium.launch();
const ctx = await browser.newContext({ viewport: { width: 1440, height: 900 }, deviceScaleFactor: 1 });
for (const [name, url] of urls) {
const page = await ctx.newPage();
try {
await page.goto(BASE + url, { waitUntil: 'load', timeout: 20000 });
await page.waitForTimeout(800);
await page.screenshot({ path: path.join(OUT, `${name}.png`), fullPage: true, type: 'png' });
console.log(`✓ ${name} ${BASE}${url}`);
} catch (e) {
console.error(`✗ ${name} ${e.message}`);
} finally {
await page.close();
}
}
await browser.close();
console.log(`\nScreenshots → ${OUT}`);
console.log(`View → ${BASE}/qa-shots/`);