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.

How to upload file using Chrome ?

mallikarjunamallikarjuna Members
edited December 2012 in Sahi - Open Source
Hi,

I am new to sahi, i want to upload CSV files using Chrome.

Script code:
_click(_span("Select File"));
_setFile(_file("upload"), "C:\Users\user\Desktop\Student.csv"); // Error in this line
_click(_submit("Upload"));


Error Message
_setFile(_file("upload"), "C:\Users\user\Desktop\Student.csv");
SyntaxError: Unexpected token ILLEGAL
SyntaxError: Unexpected token ILLEGAL
at Sahi.ex (http://test.cogknit.com/_s_/spr/concat.js:3016:14)
at :1:11
Click for browser script at Dec 26, 2012 1:18:37 PM


Thanks in advance
Mallikarjuna

Answers

  • Hi,

    Can you share the link to application where you are trying to upload the file? I may help you with the script.

    Thanks,
  • gaveyomgaveyom Members
    edited December 2012
    Hi Mallikarjuna,

    try this

    <code>

    _setFile(_file("SourceFileUpload"), "D/10.txt");
    // Change the "type" attribute of file field
    if (_isIE()){
    _call(_file("SourceFileUpload").outerHTML = _file("SourceFileUpload").outerHTML.replace(/type=file/, "type=text"));
    }else{
    _call(_file("SourceFileUpload").type = "text");
    }
    // Set the value into the textbox
    _setValue(_textbox("SourceFileUpload"), "D/10.txt");

    // click submit button

    </code>

    hope it will help
Sign In or Register to comment.