diff --git a/src/lib/screenshot.ts b/src/lib/screenshot.ts index 77c47d2..7a93af2 100644 --- a/src/lib/screenshot.ts +++ b/src/lib/screenshot.ts @@ -3,16 +3,18 @@ import sharp from 'sharp'; export async function getBufferFromPageScreenshot( url: string, - timeout = 30000 + timeout = 30000, + animationWaitTime = 1500 // Added animation wait time parameter ) { - // Added timeout parameter with default value try { const browser = await chromium.launch(); const page = await browser.newPage(); await page.setViewportSize({ width: 1920, height: 1080 }); - await page.goto(url, { timeout, waitUntil: 'domcontentloaded' }); // Added timeout option to page.goto() - let screenshotBuffer = await page.screenshot({ timeout }); // Added timeout option to page.screenshot() + await page.goto(url, { timeout, waitUntil: 'domcontentloaded' }); + await page.waitForTimeout(animationWaitTime); // Added wait for animations + + let screenshotBuffer = await page.screenshot({ timeout }); await browser.close(); const image = sharp(screenshotBuffer);