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.

How can I save a .pdf file ?

MagUiMagUi Members
edited November -1 in Sahi - Open Source
Hi everybody!

I need to check a .pdf file generated by our page. The system works like this: after you insert a new record, you have the option for print the data by clicking on a "print" button. If you click there, a new webpage will be opened with the pdf file.

My problem is that I dont know:
1) How to refer to the new webpage opened;
2) How to save the .pdf file, opened in a new windows of the browser, to any location (for after compare it with one that I have as benchmark)

Can anybody help me?

Thanks!

Comments

  • narayannarayan Administrators
    Sahi would automatically download files to the file system into a folder sahi/userdata/temp/download. You should then be able to use _lastDownloadedFileName, _saveDownloadedAs, and _clearLastDownloadedFileName

    If the file is not downloading automatically, add

    application/pdf
    application/x-pdf
    application/acrobat
    applications/vnd.pdf
    text/pdf
    text/x-pdf

    to

    sahi/userdata/config/download_contenttypes.txt

    Restart Sahi and the file should get downloaded. Based on the size of the file, give a _wait() after the click (that results in the download) before you use _lastDownloadedFileName etc.

    Regards,
    Narayan
  • Hi Narayan!

    Thanks for your help, I can successfully save the pdf file :)

    Now I have another question: everytime that we do a click on "print", the pdf document is opened in a new IE window. We usually have near to 60 forms to print, so this cause that a lot of IE windows are opened causing problems. There is a way to close each IE window after the pdf was generated and saved?

    Thanks,
    MagUi
Sign In or Register to comment.