-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Open
Description
Version
1.55.0
Steps to reproduce
Install playwright 1.55.0
Run this script:
from playwright.sync_api import sync_playwright
with sync_playwright() as p:
for browser_type in [p.chromium, p.firefox, p.webkit]:
browser = browser_type.launch()
page = browser.new_page()
page.goto('http://playwright.dev')
page.screenshot(path=f'example-{browser_type.name}') # no file ext here
browser.close()
Expected behavior
I expect that if I provide a path with no file type ext, and do not provide a type arg it ill save a screenshot as {path}.png
.
Actual behavior
Instead, it throws an Error because it cannot detect a valid mimetype:
Exception has occurred: Error
Unsupported screenshot mime type for path "example-chromium": None
File "/Users/kyle/project/playwright-python/playwright/_impl/_element_handle.py", line 464, in determine_screenshot_type
raise Error(f'Unsupported screenshot mime type for path "{path}": {mime_type}')
File "/Users/kyle/project/playwright-python/playwright/_impl/_page.py", line 804, in screenshot
params["type"] = determine_screenshot_type(params["path"])
File "/Users/kyle/project/playwright-python/playwright/_impl/_sync_base.py", line 115, in _sync
return task.result()
File "/Users/kyle/project/playwright-python/playwright/sync_api/_generated.py", line 9784, in screenshot
self._sync(
File "/Users/kyle/project/playwright-python/bug.py", line 8, in <module>
page.screenshot(path=f'example-{browser_type.name}')
playwright._impl._errors.Error: Unsupported screenshot mime type for path "example-chromium": None
Additional context
As of v1.55.0 this causes the --screenshot
cmd line option to capture screenshots on test complete in playwright-pytest
to no longer work, as the on_will_close_browser_context
function does not include a file type ext in the path (and does not specify a type.
I originally entered this bug for playwright-pytest
: microsoft/playwright-pytest#288
Environment
- Operating System: [Ubuntu 22.04]
- CPU: [arm64]
- Browser: [All, Chromium, Firefox, WebKit]
- Python Version: [3.12]
- Other info:
Metadata
Metadata
Assignees
Labels
No labels