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.

Function for Export excel actions

shobanashobana Members
edited November -1 in Sahi - Open Source
Hi,

There is an Export excel image in our application. By clicking that icon "File Download" Popup dialog window appears with "Open","Save","Cancel" actions.
By clicking on Open button excel sheet should open with list of names.
By clicking on Save button directory should open to save the file.
By clicking Cancel button should close the Popup window.

The scripts generated while clicking on these options are:

_click(_image("Export Excel"));
_click(_cell(_table("ec_table"), 6, 4));
_click(_image("Export Excel"));
_click(_image("Export Excel"));

_click(_image("Export Excel"));(After this script File Download Popup window appeared) and get stucked without any further actions.

And after clicking on Open button in that Popup window the following script is played back.
_click(_cell(_table("ec_table"), 6, 4));

After clicking on save button following script is played back
_click(_image("Export Excel"));

After clicking on Cancel button following script is played back.
_click(_image("Export Excel"));

But the script is not automatically played backed on Popup window actions. Is there any other option for this?

please provide me solution for this as soon as possible.

Comments

  • narayannarayan Administrators
    Hi Shobana,

    Open config/download_contenttypes.txt, and add the word "excel" on a
    line by itself.
    For example, the content may look like this:
    ---start---
    application/zip
    excel
    ---end---

    Now if you play back after restarting Sahi, you should not see any
    save as popups. Your file would be downloaded into sahi/temp folder.
    You the can assert that the file was downloaded, by doing
    _wait(2000); // add a wait if this takes a while to download.
    _assertEqual("output.xls", _lastDownloadedFileName()); // Asserts that the file downloaded in temp has this name.
    _saveDownloadedAs("c:/output_x.xls"); // copy it over to some other place.
    _clearLastDownloadedFileName(); // clear the temp file name for further assertions.
    
    Let me know if that works for you.
Sign In or Register to comment.