18 January 2026:


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

stevePolackstevePolack Members
edited March 2013 in Sahi - Open Source

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

  • Is the issue is resolved I am having the same issue. The file is getting saved in my respective folder but with ZERO bites.

    here goes my script-
    _assertNull(_lastDownloadedFileName());
    _click(_popup("PaymentLounge")._button("Download Form"));
    _saveDownloadedAs("c:/path/FACEBOOK.pdf");
    _clearLastDownloadedFileName();
    _assertNull(_lastDownloadedFileName());
  • I haven't found a work around yet
  • Thanks but let me know if you find any work around on it.
  • Hey the issue resolved. I did the following thing-

    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
  • Hi i am getting another issue. I have 5 diff country and for that i am downloading 5 different PDF . But for my first country it is downloading 0 kb PDF and rest of it is downloading. here goes the code-

    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
Sign In or Register to comment.