playwright icon indicating copy to clipboard operation
playwright copied to clipboard

During screenshot My Screen resolution gets reduced and once screenshot is done resolution back to viewport size

Open Shubham-Feb opened this issue 1 year ago • 1 comments

HI Playwright team,

I am using Playwright Cucumber Typescript Framework, and Report is Multiple Cucumber HTML Report and I want to add the screenshot of passed step as well so below function i am using during run time .

And Viewport size I defined in Before Hooks class: await page.setViewportSize({ width: 1536, height: 864 });

whenever I am calling the takeScreenshot function during run time then Viewport size get reduced to some pixel and once function execution is done then screen size gets back to original viewport size.

No idea how to fix this,

if I am using Viewport size as null then it's working perfectly fine. Please help me to fix this issue.

ScreenShot Function:

async function takeScreenshot(world: { attach: Function }): Promise { const img = await page.screenshot({ path: ./reports/screenshot/screenshot.png, type: "png"}); world.attach(img, "image/png"); // Convert the Buffer object to a string return ./reports/screenshot/screenshot.png; }

Please let me know if any other information required.

Regards, Shubham singh

Shubham-Feb avatar Oct 15 '24 07:10 Shubham-Feb

@Shubham-Feb This is a known side-effect when your host computer device scale factor does not match the emulated device scale factor. The most common example is running tests on a HiDPI mac. There is no workaround as of today. I wonder though, why is that a problem for you?

dgozman avatar Oct 15 '24 12:10 dgozman

Closing as per above. If you still encounter problems, please file a new issue by filling in the "Bug Report" template and link to this one.

dgozman avatar Oct 21 '24 08:10 dgozman