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.
Alternate option to download a text file
HI,
I am trying to download a text file by adding text/plain MIME type in my download_contenttypes.txt file. Though this worked, it screwed up the other scenarios.
Please guide me, if download of text file can be done in an alternate way.
Thanks,
Megha
I am trying to download a text file by adding text/plain MIME type in my download_contenttypes.txt file. Though this worked, it screwed up the other scenarios.
Please guide me, if download of text file can be done in an alternate way.
Thanks,
Megha
Comments
For example if your file is called downloadMe.txt, add
.*downloadMe[.]txt.*
Save, restart Sahi and check.
Regards,
Narayan
I used the code suggested by you in download_urls.txt. Restarted my twist. But it doesnot work for me. Here is the code i have used.
public void verifyIfFileGotGenerated() throws Exception {
File textFile = MiscFunctions.lastDownloadedFile("Anemia.txt",browser);
assertTrue(textFile.exists());
assertTrue(textFile.getTotalSpace() > 0);
}
public static File lastDownloadedFile(String fileName, Browser browser) {
File oldFile = new File(SAHI_USERDATA_DOWNLOAD_LOCATION + fileName);
if (oldFile.exists()) {
oldFile.delete();
}
String path = SAHI_TEMP_DOWNLOAD_LOCATION + fileName;
browser.saveDownloadedAs(path);
return new File(SAHI_USERDATA_DOWNLOAD_LOCATION + fileName);
}
Please guide me if this is the right way to handle the download of a text file.
Thanks,
Megha
Sahi already has a method to fetch the name of the last downloaded file. You can use that instead.
For reference, this is how I handled my file download. Regards,
dkulkarni