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.
Unable to upload file using _setFile
Hi,
I am a new user to Sahi, and was trying to upload file using _setFIle.
But still i am not able to browse the file.
here is my code :
function upload()
{
_click(_button("Upload Document"));
_setSelected(_select("documentTypeId"), "Bvf Document");
_setFile(_file("document"), "C:\\Documents and Settings\\bsundharesan\\Desktop\\test.pdf");
if(_isIE())
{
_call(_file("document").outerHTML=_file("document").outerHTML.replace(/type=file/,"type=text"));
}
else
{
_call(_file("file").type="text");
}
_click(_submit("Upload"));
_click(_button("Close"));
}
the error log file in the line _setSelected(_select("documentTypeId"), "Bvf Document");
states as :
Window/Domain not found: popupNameFromStep=; derivedName=File Upload; windowName=; windowTitle=File Upload; wasOpened=1; domain=
Also there are there are javascript checks before submit to see if the filename is non-empty. So is this possible to browse file and upload using Sahi.
can anybody help me with this, Based on this i must select this tool for my application.
Thank you
Regards,
Bhavitha
I am a new user to Sahi, and was trying to upload file using _setFIle.
But still i am not able to browse the file.
here is my code :
function upload()
{
_click(_button("Upload Document"));
_setSelected(_select("documentTypeId"), "Bvf Document");
_setFile(_file("document"), "C:\\Documents and Settings\\bsundharesan\\Desktop\\test.pdf");
if(_isIE())
{
_call(_file("document").outerHTML=_file("document").outerHTML.replace(/type=file/,"type=text"));
}
else
{
_call(_file("file").type="text");
}
_click(_submit("Upload"));
_click(_button("Close"));
}
the error log file in the line _setSelected(_select("documentTypeId"), "Bvf Document");
states as :
Window/Domain not found: popupNameFromStep=; derivedName=File Upload; windowName=; windowTitle=File Upload; wasOpened=1; domain=
Also there are there are javascript checks before submit to see if the filename is non-empty. So is this possible to browse file and upload using Sahi.
can anybody help me with this, Based on this i must select this tool for my application.
Thank you
Regards,
Bhavitha
Comments
It looks like a new window is opened when you click on Upload document. If that is the case, you need to add _popup("") before the steps that happen on the newly opened window.
Regards,
Narayan
Thanks for the help.
The code with _popup("") worked, but only partial.
Becaue everthing works except that the path doesnot gets pasted in the textbox. And if i place manually the path then file gets uploaded and it works.
I tried
_setValue(_textbox("documentTypeName"),"C:\\Documents and Settings\\bsundharesan\\Desktop\\test.pdf");
But it did not work and script fails.
Can u what is the change needs to be done.
Regards,
Bhavitha
It worked. I had missed one line of code of setting the value after converting into text.
Thanks a lot for the help!!!!
Regards,
Bhavitha