18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
file download problem
Hey there everyone, I have a problem with file download in Sahi. I'm trying to download some files from an external website and I'm getting some weird behavior from Sahi. For one thing, when I click on the link, it opens a new window, so I did this:
_sendHTMLResponseAfterFileDownload(true);
_click(_link($nomLien));
_saveDownloadedAs("test.XLSX");
_sendHTMLResponseAfterFileDownload(false);
And also, here's the console output from Sahi:
-- Calling downloadFile --
https://www.agep-gbip.dsf-dfs.com/AGEP-GBIP/Rpprt/Rapports3_Reports3.aspx?mode=N
IF&culture=fr-CA&idRapport=40F55E83-D37C-4625-A2E9-29655643E98B
downloadURL = true
response.isAttachment() = false
fileName = Rapports3_Reports3.aspx
contentTypeHeader = application/vnd.openxmlformats-officedocument.spreadsheetml.
sheet.main+xml; charset=iso-8859-1
downloadContentType = true
Content-Disposition=attachment; filename="Liste des adhérents en vigueur et leurs garanties - Au 2014-06-30.XLSX"
contentDispositionForcesDownload = false
--
juil. 15, 2014 4:45:26 PM net.sf.sahi.RemoteRequestProcessor save
INFO: Downloading sahi_1a6a5837005ff042e40a53600dc9abe2baaf__Rapports3_Reports3.aspx to temp directory:
C:\Sahi\userdata\temp\download
juil. 15, 2014 4:45:26 PM net.sf.sahi.RemoteRequestProcessor downloadFile
INFO: Setting download_lastFile = Rapports3_Reports3.aspx
Session Id: sahi_1a6a5837005ff042e40a53600dc9abe2baaf
Now, I have a few problems. Here's the list:
1) Instead of the actual file, download_lastFile is set to the name of the page that actually starts the download and not the name of the file
2) _saveDownloadedAs creates an empty file while the actual file is downloaded in the default temp folder.
3) Sahi injects html inside the downloaded file rendering it unreadable unless I actually delete the added content.
Anybody have any idea? I added
.*Rapports3_Reports3[.]aspx.*
to the exclude_inject.txt file without success. Anyone has any idea?
Thanks in advance,
Osuwariboy
_sendHTMLResponseAfterFileDownload(true);
_click(_link($nomLien));
_saveDownloadedAs("test.XLSX");
_sendHTMLResponseAfterFileDownload(false);
And also, here's the console output from Sahi:
-- Calling downloadFile --
https://www.agep-gbip.dsf-dfs.com/AGEP-GBIP/Rpprt/Rapports3_Reports3.aspx?mode=N
IF&culture=fr-CA&idRapport=40F55E83-D37C-4625-A2E9-29655643E98B
downloadURL = true
response.isAttachment() = false
fileName = Rapports3_Reports3.aspx
contentTypeHeader = application/vnd.openxmlformats-officedocument.spreadsheetml.
sheet.main+xml; charset=iso-8859-1
downloadContentType = true
Content-Disposition=attachment; filename="Liste des adhérents en vigueur et leurs garanties - Au 2014-06-30.XLSX"
contentDispositionForcesDownload = false
--
juil. 15, 2014 4:45:26 PM net.sf.sahi.RemoteRequestProcessor save
INFO: Downloading sahi_1a6a5837005ff042e40a53600dc9abe2baaf__Rapports3_Reports3.aspx to temp directory:
C:\Sahi\userdata\temp\download
juil. 15, 2014 4:45:26 PM net.sf.sahi.RemoteRequestProcessor downloadFile
INFO: Setting download_lastFile = Rapports3_Reports3.aspx
Session Id: sahi_1a6a5837005ff042e40a53600dc9abe2baaf
Now, I have a few problems. Here's the list:
1) Instead of the actual file, download_lastFile is set to the name of the page that actually starts the download and not the name of the file
2) _saveDownloadedAs creates an empty file while the actual file is downloaded in the default temp folder.
3) Sahi injects html inside the downloaded file rendering it unreadable unless I actually delete the added content.
Anybody have any idea? I added
.*Rapports3_Reports3[.]aspx.*
to the exclude_inject.txt file without success. Anyone has any idea?
Thanks in advance,
Osuwariboy
Answers
_click(_submit("PDF"));
_saveDownloadedAs("c:/path/Report.pdf"); // save to another path
_clearLastDownloadedFileName(); // clear the variable
javascript:__doPostBack('ctl00$contenuPrincipal$lstRapports$ctl01$lnkAfficherRapport','')
These open a new window which then downloads the file before closing itself automatically. The website is external so I have no control over anything. Also:
1) Instead of the actual file, download_lastFile is set to the name of the page that actually starts the download and not the name of the file
2) _saveDownloadedAs creates an empty file while the actual file is downloaded in the default temp folder.
3) Sahi injects html inside the downloaded file rendering it unreadable unless I actually delete the added content.
So I'm still rather stumped as to what's going on