44 lines
1.5 KiB
JavaScript
44 lines
1.5 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';
|
|
await page.goto(url, { waitUntil: 'networkidle2', timeout: 15000 });
|
|
await new Promise(r => setTimeout(r, 2000));
|
|
|
|
// Scroll to DatePicker section
|
|
await page.evaluate(() => {
|
|
const el = document.getElementById('sec-datepicker');
|
|
if (el) el.scrollIntoView({ behavior: 'auto' });
|
|
});
|
|
await new Promise(r => setTimeout(r, 800));
|
|
|
|
// Click on the single input range picker trigger
|
|
const spans = await page.$$('span');
|
|
for (const span of spans) {
|
|
const text = await page.evaluate(el => el.textContent, span);
|
|
if (text && text.includes('2026-06-01 至 2026-07-31')) {
|
|
await span.click();
|
|
break;
|
|
}
|
|
}
|
|
await new Promise(r => setTimeout(r, 800));
|
|
|
|
const shotDualCalendarPath = path.resolve('.tmp-ds-showcase-single-input-dual-calendar.png');
|
|
await page.screenshot({ path: shotDualCalendarPath, fullPage: false });
|
|
console.log(`Captured Single Input Dual Calendar Popover screenshot to ${shotDualCalendarPath}`);
|
|
|
|
await browser.close();
|
|
}
|
|
|
|
main().catch(console.error);
|