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.
_setFile on IE8 : always File not found
Hi all,
I use the _setFile on Firefox with succes for a long time but i must to use it with IE8 and now i ve a problem
With Firefox, The "else" works fine.
In IE8 The transformation _file("file") in textType is OK but the _setFile doesnt work : i have the following message
Naturally the file really exists
A simple question but why ?!?
why the massage about base directory ? a problem in concat.js ?
Thank you so
Fabrice
I use the _setFile on Firefox with succes for a long time but i must to use it with IE8 and now i ve a problem
if (_isIE())
{
_setFile(_file("file"), "");
// _setFile(_file("file"), "\\\\MyServer\\TestReport");
_setFile(_file("file"), "E:\\TestReport");
_call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=file/, "type=text"));
_highlight(_parentTable(_textbox("name")));
_setValue(_textbox(1, _in(_parentTable(_textbox("name")))), $TemplatePath);
}
else
{
_call(_file("file").type = "text");
// Set valeur du fichier a uploader dans le champ texte
_setValue(_textbox("file"), $TemplatePath);
}
With Firefox, The "else" works fine.
In IE8 The transformation _file("file") in textType is OK but the _setFile doesnt work : i have the following message
_setFile(_file("file"), "E:\\\\TestReport");
Error: File not found: E:\\TestReport; Base directory is userdata directory:\Program Files\InstallSahiProject\userdata
Naturally the file really exists
A simple question but why ?!?
why the massage about base directory ? a problem in concat.js ?
Thank you so
Fabrice
Comments
Kindly check if the path to the file and name of the file is correct.
If there are javascript validations on the file field, you can try this hack. Before submitting the file, change the field’s type to “text”, and then set its value.
Also, have a look at : http://sahi.co.in/w/_setFile
Use the above script and check if it works fine.
Regards
Sumitra
HArg it is my fault, i forget the extension, but it is not enough
I no longer have error, but i cant set the file
I think the problem is not the transformation of "type=file" to "type=text",
The problem arrived when i clicked on OK after this transformation : i've a message "a file must selected" on my application, so the transformation "file" to "text" isnt enough, like if the first command (2 firsts lines on your response) isnt set
// set the file
_setFile(_file("file"), "Path to the file");
This command gives the _SetFile and it is not possible to bypass that.
On firefox it works, on IE8 not
to simplify my test
After that, my field "file" transformed in field "text" contains E:\\TestReport.docx, but when i clic OK on my application, i ve a message "file must be selected". No error in logs.
I dont understand
Thank you
Fabrice
Could you check if path to the file is been visible on the textbox to you before you click on OK?
Also,try this: Obtain the identifier for the textbox next to the browse button.
Now, in your if(_isIE()) condition,
Add,
Check if this solves your issue.
Regards
Sumitra
sorry does not works, my test is now
and i still have "File must be selected"
Thank you for your spent time
Fabrice
Check if the URL to which the form is being submitted is correct. Sometimes the URL is changed when the form is submitted, and Sahi needs to be told about it using the 3rd parameter in _setFile.
Regards
Sumitra
I'm looking for that... how to know what is this third part ?
Thx
regards
Fabrice
You will have to check if the form's action URL and the URL after you set the file are different or same.
The Syntax:
_setFile(element, filePath [, actionURL])
The parameters are:
•element: HTML Form File Element whose value needs to be set
•filePath: Path of the file to be uploaded.
•actionURL: The form action URL to which the file is submitted. This is an optional parameter. Use it in cases where the form’s action URL is changed on setting the file. By default, it uses the form’s current action URL.
_setFile(_file("id"), "C:\\abc\\efg.jpg");
_setFile(_file("id"), "C:\\abc\\efg.jpg", "formSubmit.jsp");
Let me know if you face any issue.
Regards
Sumitra