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.
PDF Downloaded With Zero Bytes
Hi folks,
I have a cell which when clicked will show a PDF in seperate popup. I have run the following code, but appears that the pdf is downloaded with 0 bytes and I'm struggling to get it to work.
_sendHTMLResponseAfterFileDownload(true);
_click(_cell("48.19"));
if (_lastDownloadedFileName() != null)
{
_saveDownloadedAs("c:\\test.pdf");
}
_clearLastDownloadedFileName();
commonFunctions.showPDFText("c:\\test.pdf");
Version is: 2012-09-26 14:44:11
Answers
here goes my script-
_assertNull(_lastDownloadedFileName());
_click(_popup("PaymentLounge")._button("Download Form"));
_saveDownloadedAs("c:/path/FACEBOOK.pdf");
_clearLastDownloadedFileName();
_assertNull(_lastDownloadedFileName());
Add two thing in download_urls.txt
.*/[.]pdf
.*/[.]html
Add -
application/.pdf
And below is the code-
_popup("PaymentLounge")._click(_button(4));
_wait(9000);
_saveDownloadedAs("c:/path/"+$FileName+".pdf");
Here one issue is the browser (blank) is not closing and for next transaction it is using that browser. So can you please tell me how we can close that browser in sahi.Because that browser usually close when u save the file in manually.
And another help is how can i verify the file is created in my respective folder. got this function to use but dont know it will work or not ?
_assertEqual("setup.exe", _lastDownloadedFileName());
Thanks
Gyanadeep
var $FileName= $CountryCode+"Mandate"+ _random(10000)
_popup("PaymentLounge")._click(_button(4));
_assertNotNull(_lastDownloadedFileName());
_saveDownloadedAs("c:/path/"+$FileName+".pdf");
_wait(20000);
If i am using _assertNull(_lastDownloadedFileName()); then it is downloading my PDF with size 0kb.
Any thoughts around this.
Gyanadeep