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 problem

chirutachiruta Members
edited November -1 in Sahi - Open Source
I am trying to upload a file. Script doesnot fail but the file as well is not getting uploaded. I am not able to figure out the reason.

Comments

  • Hi chiruta

    please use this forums search function. With the keyword "file upload" you will find hundrets of posts :)

    Regards
    Wormi
  • chirutachiruta Members
    edited May 2012
    I have tried to use the methods posted in the forum but unable to upload a file.
    Here is my code.

    _setValue(_textbox("username"), "abc");
    _setValue(_password("password"), "aaa");
    _click(_imageSubmitButton("btn_login"));
    _click(_link("New Virtual Room"));
    _click(_link("Signature Room"));

    _popup("_new")._setValue(_textbox("veridationRoom:roomName"), "testing");
    _popup("_new")._click(_submit("Save "));
    _popup("_new")._click(_image("B_Add.gif"));
    _wait(10000);

    _popup("uploadDoc")._setFile(_file("documet"), "C:\\Sahi\\userdata\\scripts\\Minor issues.doc");
    _popup("uploadDoc")._call(_file("documet").type="text");
    _popup("uploadDoc")._setValue(_textbox("documet"), "C:\\Sahi\\userdata\\scripts\\Minor issues.doc");
    _wait(10000);
    _popup("uploadDoc")._click(_button("Upload"));
    _wait(10000);
    _popup("uploadDoc")._click(_submit("Done"));
    _popup("_new")._click(_image("ParticipantsOff.png"));
    _popup("_new")._click(_image("B_Add.gif[1]"));

    _popup("attendee")._setSelected(_select("filterByRole"), "Signator");

    _popup("attendee")._click(_checkbox("on[1]"));
    _popup("attendee")._click(_submit("Add to List"));

    _popup("attendee")._click(_submit("Done"));
    _popup("_new")._click(_submit("Close[1]"));
    _click(_span("Logout"));
    --Stopped Playback: SUCCESS--


    Then i also tried to replace the the file upload code with :

    popup("uploadDoc")._setFile(_file("documet"), "C:\\Sahi\\userdata\\scripts\\Minor issues.doc");
    if (_isIE()){
    _popup("uploadDoc")._call(_file("documet").outerHTML = _file("documet").outerHTML.replace(/type=file/, "type=text"));
    }else{
    _popup("uploadDoc")._call(_file("documet").type = "text");
    }
    _popup("uploadDoc")._setValue(_textbox("documet"), "C:\\Sahi\\userdata\\scripts\\Minor issues.doc");
    _wait(10000);
    }_popup("uploadDoc")._click(_button("Upload"));

    Still the playback is success with no file uploaded.

    The application has Browse and Upload buttons and a Textbox to display the file path. When the script reaches the Upload popup, i can see the Browse button, Upload button and text box. After executing the file upload statements in the script, the test box shows the complete path to the file and suddenly Browse button disappears.

    Even Manually clicking the upload button then doesnot show the file name in the table below as it should actually do.


    Please help me with what is wrong in the script?
  • I am still looking for a solution. Plese help me figure out the problem in the code and solution to it.
  • chirutachiruta Members
    I request any of the administrators to look into the posted code and figure out the issue for me.

    Thanks
  • Hi chiruta,

    Try replacing your 2 forward slashes with one backslash.
    i.e.
    C:\\Sahi\\userdata\\scripts\\Minor issues.doc = C:/Sahi/userdata/scripts/Minor issues.doc
    

    Cheers.
  • chirutachiruta Members
    Hi lonely_girl01,

    I have tried with / as well and it is not working.
Sign In or Register to comment.