How can I customize the size of a full-page screenshot in Playwright?


Sure, you can customize the size of a full-page screenshot in Playwright. You just need to use the clip option in the .screenshot() method. This option lets you define the x-coordinate, y-coordinate, width, and height of the clipping area for the image.

Here's a quick example:

await page.screenshot({
  path: 'screenshot.png',
  fullPage: true,
  clip: { x: 0, y: 0, width: 800, height: 600 }

In this code, fullPage is set to true to capture the entire scrollable page. The clip object is used to capture an area starting from coordinates (x=0, y=0) with a width of 800 pixels and a height of 600 pixels.

By tweaking the values in the clip object, you can adjust the size of your full-page screenshot to your liking.

Remember, this information is based on the current Playwright documentation. If there are any changes to the API or if you have specific requirements not covered here, it's best to refer to the official documentation.


Thank you!
Was this helpful?
Still have questions?

If you still have questions, please ask a question and I will try to answer it.

Related Discord Threads

Related Questions

AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email luc@ray.run.