Skip to content

Automatic screenshots on test completion no longer working with Playwright 1.55.0 #288

@kyleoperix

Description

@kyleoperix

I noticed in my tests, we are no longer getting screenshots when tests complete using the --screenshot cli arg with on or only-on-failure after upgrading to Playwright 1.55.0.

This PR in the playwright-python package I think introduced this: microsoft/playwright-python#2951

This introduced this if statement to determine the file type based on path if a type isn't provided.

if "type" not in params:
                params["type"] = determine_screenshot_type(params["path"])

The on_will_close_browser_context function in playwright-pytest does not provide a type arg to page.screenshot, nor is there a file extension in the screenshot_path. This function then catches all Errors and passes, so this silently fails.

def on_will_close_browser_context(self, context: BrowserContext) -> None:

I can submit a pull request to fix this, but I can see a couple of ways to fix this and I don't know which would be preferred by the maintainers:

  1. Add a ".png" to the end of the screenshot_path variable.
  2. Add a default "type" arg to the screenshot method in the playwright-python package

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions