← back to Beverlyhillsvideos App
store/capture-ipad.mjs
20 lines
import pkg from '/Users/macstudio3/.npm-global/lib/node_modules/playwright/index.js'; const { chromium } = pkg;
const shots = [
{url:'https://beverlyhillsvideos.com/', file:'01-home.png', wait:2500},
{url:'https://beverlyhillsvideos.com/videos.html', file:'02-videos.png', wait:3500},
{url:'https://beverlyhillsvideos.com/map.html', file:'03-map.png', wait:4000},
{url:'https://beverlyhillsvideos.com/restaurants/spago.html', file:'04-spago.png', wait:2500},
{url:'https://beverlyhillsvideos.com/restaurants.html', file:'05-list.png', wait:2000},
];
// iPad Pro 12.9" portrait: 1024x1366 CSS @2x = 2048x2732 device px (Apple's required size)
const b = await chromium.launch();
const ctx = await b.newContext({ viewport:{width:1024,height:1366}, deviceScaleFactor:2, isMobile:true, hasTouch:true });
const page = await ctx.newPage();
for (const s of shots) {
try { await page.goto(s.url, {waitUntil:'networkidle', timeout:30000}); } catch { await page.goto(s.url, {waitUntil:'domcontentloaded'}); }
await page.waitForTimeout(s.wait);
await page.screenshot({ path:'store/ipad/'+s.file });
console.log('captured', s.file);
}
await b.close();