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.

Sahi 5xx Error when upload a file

zwdhdzwdhd Members
edited May 2011 in Sahi - Open Source
hi all,
I am using sahi to upload a file.
I changed the type of the 'file' element to 'text', because the uploaded file should not be empty.
After I submit the form, here goes the problem.
The web server threw a 500 Internal Server Error at Thu May 05 09:18:31 CST 2011.
How can I handle it?

Comments

  • SumitraSumitra Members
    Hi zwdhd,

    Can you post the Sahi script which you are using to upload the data.

    Also, post the HTML of the file upload element.

    Regards
    Sumitra
  • ArmorArmor Members
    I have the same problem. SAHI script looks like this:

    "_setFile(_file("fileContent"), "D:\\amaltsev\\sahi\\userdata\\test22.docx");

    if (_isIE()){
    _call(_file("fileContent").outerHTML = _file("fileContent").outerHTML.replace(/type=file/, "type=text"));
    }else{
    _call(_file("fileContent").type = "text");
    }
    _setValue(_textbox("fileContent"), "test22.docx");
    _click(_button("button twDocAttachmentOkButton"));
    "
  • SumitraSumitra Members
    Hi Armor,

    Kindly check if you are getting any error on Sahi console and post the content of it.

    Can you post the logs of the script?

    Regards
    Sumitra
  • ArmorArmor Members
    As I understand there're no errors in console. It looks like this:

    "INFO: realm=; getRequestingScheme()=ntlm
    29.07.2011 13:58:13 net.sf.sahi.config.SahiAuthenticator getPasswordAuthenticati
    on
    INFO: getRequestingProtocol() = http
    29.07.2011 13:58:13 net.sf.sahi.config.SahiAuthenticator getPasswordAuthenticati
    on
    INFO: realm=; getRequestingScheme()=ntlm
    url: **** (there is correct url here)
    command: FileUpload_appendFiles
    29.07.2011 13:59:02 net.sf.sahi.command.FileUpload appendFiles
    INFO: Uploading: fileName = D:\amaltsev\sahi\userdata\test22.docx resolved to D:
    \amaltsev\sahi\userdata\test22.docx
    29.07.2011 13:59:35 net.sf.sahi.config.SahiAuthenticator getPasswordAuthenticati
    on
    INFO: getRequestingProtocol() = http
    29.07.2011 13:59:35 net.sf.sahi.config.SahiAuthenticator getPasswordAuthenticati
    on"

    The log looks like this:
    "_popup("Регистрация нового договора")._click(_button("Добавить документ")); at 29.07.2011 13:58:43
    _popup("Регистрация нового договора")._setSelected(_select("fileType"), "Файл"); at 29.07.2011 13:58:43
    _popup("Регистрация нового договора")._click(_file("fileContent")); at 29.07.2011 13:58:43
    _popup("Регистрация нового договора")._setFile(_file("fileContent"), "D:\\amaltsev\\sahi\\userdata\\test22.docx"); at 29.07.2011 13:58:43
    _sahi.setServerVar('___lastValue___1311933523709', _isIE()); at 29.07.2011 13:58:43
    _popup("Регистрация нового договора")._call(_file("fileContent").type = "text"); at 29.07.2011 13:58:43
    _popup("Регистрация нового договора")._setValue(_textbox("fileContent"), "test22.docx"); at 29.07.2011 13:58:43
    _popup("Регистрация нового договора")._click(_button("button twDocAttachmentOkButton")); at 29.07.2011 13:58:44
    The web server threw a 500 Internal Server Error at Fri Jul 29 13:58:44 MSD 2011. at 29.07.2011 13:58:44"
  • SumitraSumitra Members
    Hi Armor,

    Can you check with the latest version of Sahi?

    Regards
    Sumitra
  • ArmorArmor Members
    I use the last version (19-07-2011)
  • the source code is :

    @browser.file("user[company_attributes][qualifications_attributes][0][pictures_attributes][0]Attachment not found.
    Sumitra wrote:
    Hi Armor,

    Kindly check if you are getting any error on Sahi console and post the content of it.

    Can you post the logs of the script?

    Regards
    Sumitra
  • btw: I am using Ruby to write the test code.
    zwdhd wrote:
    the source code is :

    @browser.file("user[company_attributes][qualifications_attributes][0][pictures_attributes][0]Attachment not found.
    Sumitra wrote:
    Hi Armor,

    Kindly check if you are getting any error on Sahi console and post the content of it.

    Can you post the logs of the script?

    Regards
    Sumitra
  • html code:

    <input id="user_company_attributes_qualifications_attributes_0_pictures_attributes_0_attach" class="need_checked" type="file" onpaste="return false;" onkeypress="return false;" onblur="return check_company_qualifications_picture(this);" name="user[company_attributes][qualifications_attributes][0][pictures_attributes][0]Attachment not found.
  • Hi zwdhd,

    Sahi's "file" method takes care of file upload. You can use that instead of calling an execute_step. Having said this, please verify your input id.
    According to your html, it is "user_company_attributes_qualifications_attributes_0_pictures_attributes_0_attach" but the script given has "user[company_attributes][qualifications_attributes][0][pictures_attributes][0]Attachment not found.
        @browser.navigate_to(@base_url)
        @browser.file("user_company_attributes_qualifications_attributes_0_pictures_attributes_0_attach").file = "F:/winter.JPG";
        @browser.execute_step("_sahi._call(_sahi._file('user_company_attributes_qualifications_attributes_0_pictures_attributes_0_attach').type = 'text')")
        @browser.textbox("user_company_attributes_qualifications_attributes_0_pictures_attributes_0_attach").value = "F:/winter.JPG";
    

    This code works on any browser other than IE.
    For IE, you will have to use
    _call(_file("file").outerHTML = _file("file").outerHTML.replace(/type=file/, "type=text"));
    

    Regards,
    dkulkarni
Sign In or Register to comment.