18 January 2026:


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.

File upload issue

mohanmohan Members
edited November -1 in Sahi - Open Source
i am getting this error when i try to upload photo or text file

_setFile(_file("imgFileUpload"), "scripts/Capture.JPG");
TypeError: 'form' is null or not an object
No trace available
Click for browser script at Feb 21, 2012 6:36:28 PM



Here is my script


_popup(/App.*/)._click(_imageSubmitButton("imgNameFrontView"));
_popup(/UpdateAllImg.*/)._click(_submit("Add New"));
_popup(/UpdateImg.*/)._blur(_textbox("dttPhotoDate\$Date\$KPIDttmCtrl"));
_popup(/UpdateImg.*/)._blur(_textbox("dttPhotoDate_Time_t"));
_popup(/UpdateImg.*/)._highlight(_textbox("dttPhotoDate_Time_t"));
_popup(/UpdateImg.*/)._blur(_textbox("dttPhotoDate_Time_t"));
_popup(/UpdateImg.*/)._click(_textbox("dttPhotoDate_Time_t"));

//set the file
_setFile(_file("imgFileUpload"), "scripts/Capture.JPG");
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("imgFileUpload").outerHTML = _file("imgFileUpload").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("imgFileUpload").type = "text");
}
// Set the value into the textbox
_popup(/App.*/)._setFile(_file("imgFileUpload"), "scripts/Capture.JPG");

Comments

  • Hi Mohan,

    Can you specify the error displayed on the Sahi console?

    Ensure that the file path is specified correctly and the _file element is identified with appropriate identifier with popup id if exists.

    Regards,
    Theeran.
  • Hi Theeran,

    The form is validating before submission. how to proceed after this , its says not a valid file.
  • _popup(/App.*/)._click(_imageSubmitButton("imgNameFrontView"));
                _popup(/UpdateAllImg.*/)._click(_submit("Add New"));
                _popup(/UpdateImg.*/)._blur(_textbox("dttPhotoDate\$Date\$KPIDttmCtrl"));
                _popup(/UpdateImg.*/)._blur(_textbox("dttPhotoDate_Time_t"));
                _popup(/UpdateImg.*/)._highlight(_textbox("dttPhotoDate_Time_t"));
                _popup(/UpdateImg.*/)._blur(_textbox("dttPhotoDate_Time_t"));
                _popup(/UpdateImg.*/)._click(_textbox("dttPhotoDate_Time_t"));
                
                //set the file 
                        _popup(/App.*/)._setFile(_file("imgFileUpload"), "C:/Documents and Settings/XPMUser/sahi/userdata/scripts/001.JPG", "frmUpdateImg.js");
                    // Change the "type" attribute of file field
                    if (_isIE()){
                    _popup(/UpdateImg.*/)._call(_file("imgFileUpload").outerHTML = _file("imgFileUpload").outerHTML.replace(/type=file/, "type=text"));
                    }else{
                    _popup(/UpdateImg.*/)._call(_file("imgFileUpload").type = "text");
                    }
                    // Set the value into the textbox
                    _popup(/App.*/)._setValue(_textbox("imgFileUpload"), "C:/Documents and Settings/XPMUser/sahi/userdata/scripts/001.JPG", "frmUpdateImg.js");
                    _popup(/UpdateImg.*/)._click(_imageSubmitButton("Save & Close"));
                    _click(_button("Yes"));
                    _click(_button("No"));
                    _popup(/UpdateAllImg.*/)._click(_image("frmHandle.aspx"));
                    _popup(/UpdateAllImg.*/)._click(_submit("Update"));
                    _popup(/App.*/)._click(_imageSubmitButton("Save"));
                    _click(_button("Yes"));
                    
    
  • Not able to change the field type file to Text. we are using telerik Rad controls .
Sign In or Register to comment.