import { chromium } from 'playwright'; const browser = await chromium.launch(); const out = {}; for (const [label, vp, mobile] of [['mobile', { width: 390, height: 844 }, true], ['desktop', { width: 1280, height: 950 }, false]]) { const ctx = await browser.newContext({ viewport: vp, isMobile: mobile, hasTouch: mobile }); const page = await ctx.newPage(); await page.goto('http://localhost:5186/en/weather/week/berlin/', { waitUntil: 'load', timeout: 120000 }); await page.waitForTimeout(14000); out[label] = await page.evaluate(() => ({ rows: [...document.querySelectorAll('tr')].map((r) => ({ label: r.querySelector('.hdr')?.textContent?.trim().replace(/\s+/g, ' ').slice(0, 10) || '-', h: Math.round(r.getBoundingClientRect().height) })), tableHeight: Math.round(document.querySelector('table').getBoundingClientRect().height) })); await page.screenshot({ path: `/tmp/rows-${label}.png`, clip: { x: 0, y: 0, width: vp.width, height: Math.min(820, vp.height) } }); await ctx.close(); } console.log(JSON.stringify(out, null, 1)); await browser.close();