import { Page , ScreenshotClip } from "puppeteer-core" ; export async function getElementClip ( page , selector ) { return await page . evaluate ( ( selector ) => { const target = document . querySelector ( selector ) ; if ( target ) { let { x , y , width , height } = target . getBoundingClientRect ( ) || { } ; return { x , y , width , height } ; } } , selector ) ; } export async function sleep ( period ) { return await new Promise ( ( r ) => setTimeout ( r , period ) ) ; }