Skip to content

connect_over_cdp always download file to tmp folder #2105

Closed as not planned
Closed as not planned

Description

@hackerpayne

I always use existing chrome do my job.

pw.chromium.connect_over_cdp(f'http://127.0.0.1:5566/', timeout=0)

works well.

Most of the time, I operate automatically, but often I need to manually download the results. At such times, the downloaded files end up being stored in a hard-to-find location.

the file always download to tmp folder like :
C:\Users\ADMINI~1\AppData\Local\Temp\2\playwright-artifacts-k8550A\c78a1a06-9d11-4eab-a4ed-d02323dff07e

hope some one can improve this .or is there any ways to set default download path when using cdp connection.

like pw.chromium.launch use downloads_path param to set default download place.
browser=pw.chromium.launch(downloads_path='c:/')

In that case, it would be very convenient.

Activity

  1. mxschmitt commented on Oct 9, 2023

    @mxschmitt
    Contributor

    This path is not intended to be consumed, thats why the file names are also UUIDs. We have a Download API, with which you can get the location, save it to a different location and delete the file. See here: https://playwright.dev/python/docs/downloads

    You can also subscribe to the download event:

    def handle_download(download: Download):
        download.save_as("...")
        download.delete()
    page.on("download", handle_download)

    Would that work for you?

  2. hackerpayne commented on Oct 9, 2023

    @hackerpayne
    Author

    Thanks for this code。this code works fine.

    but i think add a param like downloads_path would be more convenient.

    Anyway thanks very much .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions