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

kapilkapil Members
edited November -1 in Sahi - Open Source
Hi , sumitra

I had gone through your suggested document but controller shows same error message.
here i am posting my script for your reference.

Starting script
_click(_cell("Accounts Payable")); at Jul 19, 2011 12:31:25 PM
_click(_cell("AP Processor")); at Jul 19, 2011 12:31:25 PM
_click(_cell("AP Processor")); at Jul 19, 2011 12:31:27 PM
_click(_cell("Enter Invoice")); at Jul 19, 2011 12:31:27 PM
_click(_button("dbcPurchaseOrder_ulbSearchButton")); at Jul 19, 2011 12:31:31 PM
_setSelected(_select("dbcPurchaseOrder\$ulbDropDown"), "0011806"); at Jul 19, 2011 12:31:34 PM
_setValue(_textbox("txtInvoiceNumber"), "1960"); at Jul 19, 2011 12:31:39 PM
_click(_image("Click here to view the calendar")); at Jul 19, 2011 12:31:39 PM
_click(_cell("12")); at Jul 19, 2011 12:31:39 PM
_click(_cell("12")); at Jul 19, 2011 12:31:39 PM
_setValue(_textbox("txtInvoiceAmount"), "100"); at Jul 19, 2011 12:31:40 PM
_click(_image("Click here to view the calendar[3]")); at Jul 19, 2011 12:31:40 PM
_click(_image("Click here to view the calendar[3]")); at Jul 19, 2011 12:31:40 PM
_click(_cell("10")); at Jul 19, 2011 12:31:40 PM
_click(_cell("10")); at Jul 19, 2011 12:31:40 PM
_setValue(_textarea("txtInvoiceDescription"), "kapil"); at Jul 19, 2011 12:31:41 PM
_click(_submit("Edit")); at Jul 19, 2011 12:31:41 PM
_setValue(_textbox("dtgrdTaskDistribution\$ctl02\$txtDistribution"), "100.00"); at Jul 19, 2011 12:31:46 PM
_click(_submit("Update")); at Jul 19, 2011 12:31:46 PM
_click(_submit("Upload New Document")); at Jul 19, 2011 12:31:52 PM
ERROR
ReferenceError: "setFile" is not defined. at Jul 19, 2011 12:31:52 PM

i am facing problem from
_click(_submit("Upload New Document")); at Jul 19, 2011 12:31:52 PM
line please suggest me solution so that i can proceed further
Validation on upload document, i am using IE 9, Application environment is C#.net,ASP

Thank you,

regards,

kapil

Comments

  • SumitraSumitra Members
    Hi Kapil,

    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. Eg.
    // set the file
        _setFile(_file("file"), "scripts/demo/uploadme.txt");
           // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=file/, "type=text"));
        }else{
            _call(_file("file").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("file"), "scripts/demo/uploadme.txt");
    

    Let me know if you face any problem

    Kindly post the recorded script here.

    Regards
    Sumitra
  • kapilkapil Members
    Thanx for the reply....

    i have tried that syntax also .. but not getting exactly what to chang in script..
    for that only i have posted the whole script....will u please help me out.
    file word means exact file name or what?.... not getting properly

    Regards,
    Kapil
  • SumitraSumitra Members
    Hi Kapil,

    Kindly post the recorded script here.

    Regards
    Sumitra
  • kapilkapil Members
    hello mam,

    here is the script

    _click(_cell("Accounts Payable"));
    _click(_cell("AP Processor"));
    _click(_cell("AP Processor"));
    _click(_cell("Enter Invoice"));
    _click(_button("dbcPurchaseOrder_ulbSearchButton"));
    _setSelected(_select("dbcPurchaseOrder\$ulbDropDown"), "0011806");
    _setValue(_textbox("txtInvoiceNumber"), "1960");
    _click(_image("Click here to view the calendar"));
    _click(_cell("12"));
    _click(_cell("12"));
    _setValue(_textbox("txtInvoiceAmount"), "100");
    _click(_image("Click here to view the calendar[3]"));
    _click(_image("Click here to view the calendar[3]"));
    _click(_cell("10"));
    _click(_cell("10"));
    _setValue(_textarea("txtInvoiceDescription"), "kapil");
    _click(_submit("Edit"));
    _setValue(_textbox("dtgrdTaskDistribution\$ctl02\$txtDistribution"), "100.00");
    _click(_submit("Update"));
    _click(_submit("Upload New Document"));



    setFile(_file("file"), "C:\\Test.txt");
    _setFile(_file("file"), "C:\\test.txt", "formSubmit.jsp");

    _click(_submit("Save"));


    thanx'
    regards,
    kapil
  • kapilkapil Members
    hello mam,

    1. upload file document is mendatory .
    on click (upload file document ) new window pop up.. with file to to browes, and save and cancel button.

    2. after submitting that form , it does for approval process so, i want to know that whether sahi supports approval process or work flow?

    I want to implement this system for our testing purpose

    Regards,

    kapil
  • SumitraSumitra Members
    Hi Kapil,

    Kindly use the following script and let me know if it works:
    _click(_cell("Accounts Payable"));
    _click(_cell("AP Processor"));
    _click(_cell("AP Processor"));
    _click(_cell("Enter Invoice"));
    _click(_button("dbcPurchaseOrder_ulbSearchButton"));
    _setSelected(_select("dbcPurchaseOrder\$ulbDropDown"), "0011806");
    _setValue(_textbox("txtInvoiceNumber"), "1960");
    _click(_image("Click here to view the calendar"));
    _click(_cell("12"));
    _click(_cell("12"));
    _setValue(_textbox("txtInvoiceAmount"), "100");
    _click(_image("Click here to view the calendar[3]"));
    _click(_image("Click here to view the calendar[3]"));
    _click(_cell("10"));
    _click(_cell("10"));
    _setValue(_textarea("txtInvoiceDescription"), "kapil");
    _click(_submit("Edit"));
    _setValue(_textbox("dtgrdTaskDistribution\$ctl02\$txtDistribution"), "100.00");
    _click(_submit("Update"));
    _click(_submit("Upload New Document"));
    _setFile(_file("file"), "C:\\test.txt");
    // set the file
                // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=file/, "type=text"));
        }else{
            _call(_file("file").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("file"), "C:\\test.txt");
    _click(_submit("Save"));
    


    Regards
    Sumitra
  • kapilkapil Members
    Hi, sumitra

    i tried your updated script , but controller shows error message that

    _setFile(_file("file"), "C:\\test.txt");
    TypeError: Unable to get value of the property 'form': object is null or undefined
    No trace available

    is it necessory to configure Add-ons setting...
    please reply

    regards'
    kapil
  • SumitraSumitra Members
    Hi

    Kindly Ctrl+Hover on the file input on new window pop up and check what the accessor field displays.

    Regards
    Sumitra
  • kapilkapil Members
    Hi, sumitra

    here i am ctrl +Hover on the text lebel: Document File, the Accessor field displys
    1._span("Document File *") ,
    2.same in the alternatives and
    3. Document File* in value .

    and if i hold in the same way on the input textbox then accessor shows
    1._file("fileUploadInvoiceFile")

    Regards,

    Please waiting for reply

    kapil
  • kapilkapil Members
    Hi sumitra

    Is it possible to have voice chat ? or messnger ? it would be more helpful for me..

    Regards,

    kapil
  • adelmusadelmus Members
    Hej i have similar problem
    im using your hack for javascript validation

    _setFile(_file("holder"), "C:\\sahi\\userdata\\pictures\\2.jpg");

    if (_isIE()){
    _call(_file("holder").outerHTML = _file("holder").outerHTML.replace(/type=file/, "type=text"));
    }else{
    _call(_file("holder").type = "text");
    }
    _setValue(_textbox("holder"), "C:\\sahi\\userdata\\pictures\\2.jpg");

    and after changing file to text, validation still works...
    is there any other way to bypass this isue ?
    hope your wathing old forum posts :)

    regards

    Adelmus
  • kapilkapil Members
    Hello sumitra,

    As per our discussion on Jully 26, i tried your suggested code script

    _setFile(_file("fileUploadInvoiceFile"),"C:\\test.txt");
    // set the file
    // Change the "type" attribute of file field
    if (_isIE()){
    _call(_file("fileUploadInvoiceFile").outerHTML = _file("fileUploadInvoiceFile").outerHTML.replace(/type=file/, "type=text"));
    }else{
    _call(_file("fileUploadInvoiceFile").type = "text");
    }
    // Set the value into the textbox
    _setValue(_textbox("fileUploadInvoiceFile"), "C:\\test.txt");

    but unfortunately same error occured.. only difference in that was
    Add invoice window pop up , Textbox gets filled by the path: C:\\test.txt
    but after save operation form showed error message "Please attach any one invoice document"
    It means controller failed in saving that invoice document.
    Another thing, as per your documentation 'Upload file ' operation should not be visible for user as it injects while submiting the form so it is also unexpected behaviour.

    I am waiting for your reply.

    Regards,

    kapil
Sign In or Register to comment.