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.
How to handle ajax file upload
How to handle ajax file upload
I tried with below code,
but it returns error :
OS : Windows XP
Browser : Mozilla 3.6.6
Sahi Build: 2011-07-19
Thanks in advance
Jeeson
I tried with below code,
<browser>
function unsetFile (el, url) {
if (!url) url = (_sahi.isBlankOrNull(el.form.action) || (typeof el.form.action != "string")) ? _sahi.getWindow(el).location.href : el.form.action;
if (url && (q = url.indexOf("?")) != -1) url = url.substring(0, q);
if (url.indexOf("http") != 0) {
var loc = window.location;
if (url.indexOf("/") == 0){
url = loc.protocol+ "//" + loc.hostname + (loc.port ? (':'+loc.port) : '') + url;
}else{
var winUrl = loc.href;
url = winUrl.substring(0, winUrl.lastIndexOf ('/') + 1) + url;
}
}
_sahi._removeMock(url.replace(/[.]/g, "[.]"));
};
</browser>
_call(unsetFile(_file("dealImage")));
_setFile(_file("dealImage"), "image5.png");
if (_isIE()){
_call(_file("dealImage").outerHTML = _file("dealImage").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("dealImage").type = "text");
}
_setValue(_textbox("dealImage"), "image5.png");
but it returns error :
_call(unsetFile(_file("dealImage")));
TypeError: el.form is null
OS : Windows XP
Browser : Mozilla 3.6.6
Sahi Build: 2011-07-19
Thanks in advance
Jeeson
Comments
File upload should work the same way as it would without AJAX.
Have you looked at _setFile?
Do you get the same error when you run the script without _call(unsetFile(_file("dealImage")));? If yes, is it possible for you to point us to your application or a similar example available online? We could try reproducing the problem and give you a solution.
Regards,
dkulkarni
Thanks for your reply.
Yes, same error on without _call(unsetFile(_file("dealImage")));
Image uploader in our application is similar to http://www.webinfopedia.com/demo/ajax-dynamic-image-upload/
Thanks
Jeeson
Thanks
Jeeson
Thank You for the support!!