Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Support for the user given filename during download. #32692

Open
fmrahman opened this issue Sep 18, 2024 · 2 comments
Open

[Feature]: Support for the user given filename during download. #32692

fmrahman opened this issue Sep 18, 2024 · 2 comments

Comments

@fmrahman
Copy link

🚀 Feature Request

When downloading the files in Playwright the filenames are in UUID format instead of the application suggested filename. I referred to the issue 7464, where it was mentioned that this is an expected behavior.
Is it possible to override this behavior using the ignoreDefaultArgs option. Something like ignoreDefaultArgs: ['--downloadUniqueFileName'].

In my case my playwright test script takes the responsibility of the uniqueness of filenames in the directory.

Example

Example: ignoreDefaultArgs: ['--downloadUniqueFileName'].

Motivation

The filenames are important to confirm whether the specific file got downloaded. The uniqueness of the filenames are handled by the applications itself. I feel it would be better if there is an option to override the default functionality of files saving as UUID.

@mxschmitt
Copy link
Member

You can receive the real file name by calling download.suggestedFileName() see this guide. This allows you to confirm it via the code inside a test - would that work for you?

@fmrahman
Copy link
Author

Thanks @mxschmitt for the suggestion but that doesn't work for my requirement. Let me explain my use-case and the code-base in detail.
Actually we are a Synthetic Monitoring team where we capture HAR and screenshots for every click action.

We are using Chrome browser and we have our own Chrome plugin that monitors the test executions. This plugin dumps the HAR and screenshots during the respective click actions. During the dump we propose a unique filename (nano timestamp) in a different folder for every execution. We use chrome.downloads.download API for dumping. The problem is even though we are suggesting a filename the files are saved with UUID, without the extensions.

After execution we have another piece of code that parse HAR files as per its filename having extension .har and also uses the filename (timestamp) for the ordering of the visited pages. We also uses the screenshot files having extension .jpg.

Now all the filenames are in UUID format we don't know the file type from filename.

It would be great helpful for our team if you can provide the feature to ignore the default behavior of saving the files in UUID with the option ignoreDefaultArgs: ['--downloadUniqueFileName'].

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants