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.
Not able to upload file, even after passing third argument
Hi All,
I need to upload a binary file on my application. I am using this code (let say, binary file name is: "abc"):
URL (third argument) remains same, while either uploading using Sahi or uploading manually..
URL is: http://10.20.20.227:1180/corporate/webpages/index.jsp
I also tried with whole URL as third argument, but still could not succeed. As the resultant it shows Error 404: Page not found.
No error message found on Sahi console.
Please help in this.
Thanks in Advance!
I need to upload a binary file on my application. I am using this code (let say, binary file name is: "abc"):
_setFile(_file("filename"), "abc","corporate/webpages/index.jsp");
if(_isIE()){
_call(_file("filename").outerHTML = _file("filename").outerHTML.replace(/type=file/, "type=text"));
_call(_textbox("filename").value= "abc");
}
else{
_call(_file("filename").type = "text");
}
_setValue(_textbox("filename"), "abc");
_click(_button("Upload"));
URL (third argument) remains same, while either uploading using Sahi or uploading manually..
URL is: http://10.20.20.227:1180/corporate/webpages/index.jsp
I also tried with whole URL as third argument, but still could not succeed. As the resultant it shows Error 404: Page not found.
No error message found on Sahi console.
Please help in this.
Thanks in Advance!
Comments
It shows POST request on http://10.20.20.227:1180/corporate/Controller
I also tried, third argument as:
_setFile(_file("filename"), "abc","/corporate/Controller");
AND
_setFile(_file("filename"), "abc","http://10.20.20.227:1180/corporate/Controller"
but this time, "SAHI_ERROR" is displayed on the webpage.
Any help will be highly appreciated.
I am expecting some expert tips from you.
Kindly look into this.
hope this will help u, it's working fine for me, pls try this
**********************************************************************
_setFile(_file("SourceFileUpload"), "D:/fileName.txt");
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("SourceFileUpload").outerHTML = _file("SourceFileUpload").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("SourceFileUpload").type = "text");
}
// Set the value into the textbox
_setValue(_textbox("SourceFileUpload"), "D:/fileName.txt");
**********************************************************************
Regards,
G@veyom
Thanks for the response...
Browsing the file is not an issue for me. I am able to browse it successfully, using Sahi's workaround. The problem is, after clicking on "Upload" button, it is not being uploaded. Probably, due to third argument within _setFile API.
Regards,
nagar
Is it possible for you to share the file browsing work around.
I have tried the following:
_setFile(_file("SourceFileUpload"), filepath);
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("txtDocument").outerHTML = _file("txtDocument").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("v").type = "text");
}
// Set the value into the textbox
_setValue(_textbox("txtDocument"), "filepatht");
After changing the file into text, the value gets sets however when I click the "OK" button to commit changes, the converted input type changes back to input type = file and the field value becomes blank.
If there is a way to browse using sahi controller, please share.
thanks
It should not be the case, until & unless you change it's type, back to "file". May be you are changing it's type before clicking on "OK".
Does your GUI page show any error when you click "OK"?
thanks.