62 lines
2.2 KiB
JavaScript
62 lines
2.2 KiB
JavaScript
import puppeteer from 'puppeteer';
|
|
import path from 'path';
|
|
|
|
async function main() {
|
|
const browser = await puppeteer.launch({
|
|
executablePath: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
|
|
headless: true,
|
|
args: ['--no-sandbox', '--disable-setuid-sandbox']
|
|
});
|
|
|
|
const page = await browser.newPage();
|
|
await page.setViewport({ width: 1440, height: 1200, deviceScaleFactor: 2 });
|
|
|
|
const url = 'http://localhost:51720/prototypes/oneos-v2';
|
|
console.log(`Navigating to ${url}...`);
|
|
|
|
await page.goto(url, { waitUntil: 'networkidle2', timeout: 15000 });
|
|
await new Promise(r => setTimeout(r, 2000));
|
|
|
|
// 1. Capture Top Section
|
|
const shotTopPath = path.resolve('.tmp-ds-showcase-top.png');
|
|
await page.screenshot({ path: shotTopPath, fullPage: false });
|
|
console.log(`Captured Top section screenshot to ${shotTopPath}`);
|
|
|
|
// 2. Scroll to DatePicker section and click trigger to open Custom Popover
|
|
await page.evaluate(() => {
|
|
const el = document.getElementById('sec-datepicker');
|
|
if (el) el.scrollIntoView({ behavior: 'auto' });
|
|
});
|
|
await new Promise(r => setTimeout(r, 800));
|
|
|
|
// Find the single datepicker trigger and click it
|
|
const datePickerTriggers = await page.$$('div');
|
|
for (const trigger of datePickerTriggers) {
|
|
const text = await page.evaluate(el => el.textContent, trigger);
|
|
if (text && text.includes('2026-07-23') && text.length < 25) {
|
|
await trigger.click();
|
|
break;
|
|
}
|
|
}
|
|
await new Promise(r => setTimeout(r, 800));
|
|
|
|
const shotDatePickerPath = path.resolve('.tmp-ds-showcase-custom-datepicker.png');
|
|
await page.screenshot({ path: shotDatePickerPath, fullPage: false });
|
|
console.log(`Captured Custom DatePicker Popover screenshot to ${shotDatePickerPath}`);
|
|
|
|
// 3. Scroll to Composite Section
|
|
await page.evaluate(() => {
|
|
const el = document.getElementById('sec-composite');
|
|
if (el) el.scrollIntoView({ behavior: 'auto' });
|
|
});
|
|
await new Promise(r => setTimeout(r, 800));
|
|
|
|
const shotCompositePath = path.resolve('.tmp-ds-showcase-composite.png');
|
|
await page.screenshot({ path: shotCompositePath, fullPage: false });
|
|
console.log(`Captured Composite FilterBar screenshot to ${shotCompositePath}`);
|
|
|
|
await browser.close();
|
|
}
|
|
|
|
main().catch(console.error);
|