-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Version
1.54.0
Steps to reproduce
- Clone my repo at https://github.com/xianghuzhao/playwright-screenshot-bug
- uv run main.py
- Check the output file format
file save.jpeg
- The actual format for this screenshot file is PNG, not inferred from file extension JPEG
Expected behavior
The file format should be JPEG:
file save.jpeg
save.jpeg: JPEG image data, JFIF standard 1.01, aspect ratio, density 1x1, segment length 16, baseline, precision 8, 1280x720, components 3
Actual behavior
file save.jpeg
save.jpeg: PNG image data, 1280 x 720, 8-bit/color RGB, non-interlaced
Additional context
According to the documentation:
path : Union[pathlib.Path, str, None]
The file path to save the image to. The screenshot type will be inferred from file extension.
But in the example I called the screenshot method with only path argument. The file extension is .jpeg
and i got a PNG file with extension .jpeg
. This behavior happens both in page screenshot and element screenshot methods.
I also tried the node.js version of playwright and everything works correctly as the doc. I did not try other languages.
I checked the source code and found that the path argument is removed and the file extension is not checked. I forked the repo and tried to give a fix here: https://github.com/xianghuzhao/playwright-python
Environment
- Operating System: [MacOS 15.6]
- CPU: [Apple M4]
- Browser: [All, Chromium, Firefox, WebKit]
- Python Version: [3.12]
Metadata
Metadata
Assignees
Labels
No labels