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.
Save an image
Hi,
I would like to save an image but I didn't find the solution. I looked for on this forum and sahi pages but with no result.
Could you help me please?
Thanks
Martin
I would like to save an image but I didn't find the solution. I looked for on this forum and sahi pages but with no result.
Could you help me please?
Thanks
Martin
This discussion has been closed.
Comments
You can add the url of the image to be downloaded in download_urls.txt (from Configure link on Sahi Dashboard).
For example if the url of the image is "http://localhost:9999/_s_/spr/images/sahi_os_logo2.png", then add
.*images[/]sahi_os_logo2[.]png.*
Save, restart Sahi and check.
Regards
Sumitra
And do you know if exists a way to get the file name? I tried browser.lastDownloadedFileName() but it returns me "null".
EDIT: I want full name with hash code. Or set my own name.
The name is:
String fileName = browser.sessionId() + "__" + browser.lastDownloadedFileName();
There are 2 reasons for returning null when you used browser.lastDownloadedFileName() :
1) You might have deleted the file which you have downloaded.
2) Sahi prefixes the downloaded file with a session id. So, browser.lastDownloadedFileName() will return the last downloaded file as long as you are working in the same session. Else, it will return null.
You don't have to prefix a sessionId explicitly.
For more details about the file download in Sahi:
http://sahi.co.in/w/handle-file-downloads
Let me know if you are able to get the file name.
Regards
Sumitra
can u please tell me how to store image in a variable ....
this code is not working.
var $image=_image("fgrp_y.gif",_leftOf(_link($grpname)));
_log($image);
_alert(x)
output: HTMLImageElement
works fine for me. At least in the Sahi Controller
var x= _image("_sahi_ignore_2");
_alert(JSON.stringify(_sahi.list(x)))