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.

Upload a file

arunbalaarunbala Members
edited November -1 in Sahi - Open Source
Hi,
I cant upload a file. i il tel u my scripts. I jus tried with our demo example. but its not working for IE.
My script:
if (_isIE()){
_call(_file("BrowseFile").outerHTML = _file("BrowseFile").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("BrowseFile").type = "text");
}
_setValue(_textbox("BrowseFile"), "C:\Documents and Settings\Arun.B\sahi_pro\userdata\New.txt");
Pls provide me a solution

Comments

  • Hi Arun,

    Your script should be:
    _setFile(_file("BrowseFile"), "C:\Documents and Settings\Arun.B\sahi_pro\userdata\New.txt");
           // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("BrowseFile").outerHTML = _file("BrowseFile").outerHTML.replace(/type=file/, "type=text"));
        }else{
            _call(_file("BrowseFile").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("BrowseFile"), "C:\Documents and Settings\Arun.B\sahi_pro\userdata\New.txt");
    

    Check if this solves your issue.

    Regards
    Sumitra
  • Hi Sumitra,
    Its nt wrkg ya...
    the error msg is,
    _setFile(_file("BrowseFile"), "C:\\Documents and Settings\\Arun.B\\sahi_pro\\userdata\\New.txt"); SyntaxError: Expected hexadecimal digit No trace available Click for browser script at FileAttachment (scripts/InitiateTransaction.sah:30) [13219 ms]

    Thnx
  • Hi Arun,

    Try the following code:
    _setFile(_file("BrowseFile"), "C:/Documents and Settings/Arun.B/sahi_pro/userdata/New.txt");
           // Change the "type" attribute of file field
        if (_isIE()){
            _call(_file("BrowseFile").outerHTML = _file("BrowseFile").outerHTML.replace(/type=file/, "type=text"));
        }else{
            _call(_file("BrowseFile").type = "text");
        }
            // Set the value into the textbox
        _setValue(_textbox("BrowseFile"), "C:/Documents and Settings/Arun.B/sahi_pro/userdata/New.txt");
    

    Also, could you try running the setFile.sah script by navigating to <sahi-home>/userdata/scripts/demo/setFile.sah and check if you are facing any problem.

    Regards
    Sumitra
  • arunbalaarunbala Members
    edited February 2012
    Thnx sumitra.
    its wrkng fine. u ppl r dn great job.
  • Hey sumi,
    Can u pls explain the logic behind this.

    Thnx.
Sign In or Register to comment.