question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] A png screenshot is produced when a jpeg/jpg screenshot is requested

See original GitHub issue

Context:

  • Playwright Version: 1.4.2 and 1.5.1
  • Operating System: macOS, Linux
  • Node.js version: 14.1.0
  • Browser: All
  • Extra: (None)

Code Snippet


(async () => {
  for (const browserType of ['chromium', 'firefox', 'webkit']) {
    const browser = await playwright[browserType].launch();
    const context = await browser.newContext();
    const page = await context.newPage();
    await page.goto('http://whatsmyuseragent.org/');
    //await page.screenshot({ path: `example-${browserType}.png` }); //Generates .png screenshots
    await page.screenshot({ path: `example-${browserType}.png`, type: "jpeg" }); //Also generates .png screenshots
    await browser.close();
  }
})();

Describe the bug

Providing type: "jpeg" in page.screenshot()'s options parameter has no effect. I initially noticed this problem on 1.4.2. After upgrading to 1.5.1, I’m still seeing the same behavior. All generated screenshots are of type png.

Documentation reference for page.screenshot() options

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
arjunattamcommented, Oct 26, 2020

Thanks for confirming. I believe there are 2 action items:

  1. Clarify in docs that extension in path takes precedence over type.
  2. Support case where path does not have an extension, but type is specified.
0reactions
dave-cheevercommented, Jan 11, 2021

Hi Rich!

Thanks for the reply, although I figured it out with trial and error. Thank you so much for taking time to reply. And I’ll create a separate ticket if I encounter a problem.

Thanks!

On Tue, Jan 12, 2021 at 12:58 AM Rich Christiansen notifications@github.com wrote:

Hi, @dave-cheever https://github.com/dave-cheever! You can use an absolute path (/tmp/filename.png) or a relative path ( …/example/filename.png).

In the future, instead of commenting on an irrelevant Issue, please create a new Issue or Discussion.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/microsoft/playwright/issues/4238#issuecomment-758085965, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACSLDW2TRZWDPB7TEQ5EF43SZMU2JANCNFSM4S7U7NJA .

Read more comments on GitHub >

github_iconTop Results From Across the Web

Unable to attach/upload screenshot when reporting a bug
Attaching/uploading an image when reporting a bug results in the following errors: Upload failed: Failed to send request to ...
Read more >
How to Take JPEG Screenshots Instead of PNG ...
1. Crop the Photo to Get It in JPEG Format. The simplest way to turn a screenshot into a JPEG image is to...
Read more >
How to save screenshots as JPG automatically?
navigate to org > gnome > gnome-screenshot and change the default-file-type png to jpg. Share.
Read more >
Take screenshot of Web site and save it to png/jpg/bmp/tiff ...
SiteShoter is a small utility that allows you to save a screenshot of any Web page into a file.
Read more >
Video Screenshot in jpg distorted (#13862) · Issues
action: set video screenshot format to jpg in -settings -video -screenshots ... Something went wrong while fetching related merge requests.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found