-
Notifications
You must be signed in to change notification settings - Fork 293
Description
Version
1.57
Steps to reproduce
- Navigate to a site that has a file to be downloaded when a link is clicked
- The filename must be at least 91 chars in length (my scenario, but could not determine the minimum length)
- Using the page.WaitForDownloadAsync approach, use the locator corresponding the element to click and start the event, and use "await" for the download event to be completed and the IDownload object returned.
- The resulted IDownload object is returned.
Expected behavior
- The IDownload object must have the SuggestedFilename property containing the full file name.
Actual behavior
- The IDownload object SuggestedFilename property has truncated the filename, ending with an underscore and no file extension.
Additional context
I'm using .NET C# playwright library (1.57) to download some files, by clicking the element locator and using the "wait download event" approach.
It seens that, when the filename is too long, the download.SuggestedFilename property is getting truncated, ending with a underscore:
This is the c# code I'm using to download the file using the element locator:
private async Task<DownloadFile> ExecuteDownload(ILocator locator)
{
var waitDownload = _page!.WaitForDownloadAsync();
await locator.ClickAsync();
var download = await waitDownload;
var path = await download.PathAsync();
var file = DownloadFile.Create(download.SuggestedFilename, File.ReadAllBytes(path));
await download.DeleteAsync();
return file;
}
The element corresponding to the locator is this anchor:
<a href="ht2ftp.php?m_gGED=105&gfile=GRP/M_20251117/G2785279025685.pdf&gMateria=10&na=Roberto+Bittencourt+Freire+X+Light+-+Peti%E7%E3o+Inicial+-+Fornecimento+de+Energia+El%E9trica.pdf" target="_blank">
INICIAL<i> (Roberto Bittencourt Freire X Light - Petição Inicial - Fornecimento de Energia Elétrica.pdf)</i></a>
The SuggestedFilename property result is: "Roberto Bittencourt Freire X Light - Inicial - Fornecimento de Energia_".
The correct file name is "Roberto Bittencourt Freire X Light - Petição Inicial - Fornecimento de Energia Elétrica.pdf".
When using the browser developer tools to investigate the content-disposition response, it has the completed filename. Also, the download file name is also correct when manually using the browser.
Any suggestion to fix this or any workaround?
Thanks
Environment
- Operating System: [Dotnet Official Docker Image v10 - Base OS -> Ubuntu 24.04]
- CPU: [arm64]
- Browser: [Chromium]
- .NET Version (TFM): [net10.0]
- Other info: