Skip to content

Commit 5d5d65f

Browse files
authored
fix: Take page scroll into account in ElementHandle.screenshot() (#172)
1 parent 8bc945a commit 5d5d65f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/element_handle.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,11 +293,13 @@ export class ElementHandle {
293293
);
294294
}
295295

296+
const { cssLayoutViewport } = await this.#celestial.Page.getLayoutMetrics();
297+
296298
return await this.#page.screenshot({
297299
...opts,
298300
clip: {
299-
x: boxModel.border[0].x,
300-
y: boxModel.border[0].y,
301+
x: boxModel.border[0].x + cssLayoutViewport.pageX,
302+
y: boxModel.border[0].y + cssLayoutViewport.pageY,
301303
width: boxModel.border[2].x - boxModel.border[0].x,
302304
height: boxModel.border[2].y - boxModel.border[0].y,
303305
scale: opts?.scale ?? 1,

0 commit comments

Comments
 (0)