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

dgs5023dgs5023 Members
edited November -1 in Sahi - Open Source
I'm attempting to create a test that uploads a .txt file into our system but I am running into some trouble. I've searched the forums and site for a way around our blank field check and so far I've run into the following scripts, neither of which has worked:
_setFile(_file("file1"), "scripts\tryharder\goodoffers.txt");
              if (_isIE()){
        _call(_file("file1").outerHTML = _file("file1").outerHTML.replace(/type=file/, "type=text"));
    }else{
        _call(_file("file1").type = "text");
    }
        
    _setValue(_textbox("file1"), "scripts\\tryharder\\goodoffers.txt");

Which brings back the error: Proxy_Fwd: appended_strings = NULL and nothing is uploaded.

I have also used:
_call(_file("file1").outerHTML = '<input name="goodoffers" type="text" id="goodoffers" size="17.3" value=\"scripts/tryharder/goodoffers.txt\" />');

which I found on the forums, although this causes our uploading process to hang and require a restart before it can be utilized again.

If anyone can help me I'd greatly appreciate it.

Comments

  • Hi dgs5023,

    Try with the following script,
    _setFile(_file("file1"), "scripts\\tryharder\\goodoffers.txt");
                  if (_isIE()){
            _call(_file("file1").outerHTML = _file("file1").outerHTML.replace(/type=file/, "type=text"));
        }else{
            _call(_file("file1").type = "text");
        }
            
        _setValue(_textbox("file1"), "scripts\\tryharder\\goodoffers.txt");
    

    It seems like path is incorrect.

    Hope this might help you.

    Regards,
    Theeran.
  • I got this error again: Proxy_Fwd: appended_strings = NULL

    I fixed the file path and now I keep getting a failure.

    When looking at the log I saw highlighted in red the folowing:
    _setFile(_file("file1"), C:\\Users\\User\\sahi\\userdata\\scripts\\tryharder\\goodoffers.txt");
    SyntaxError: Expected ')'
    No trace available
    Click for browser script at Feb 22, 2012 9:30:29 AM
    
  • narayannarayan Administrators
    _setFile(_file("file1"), C:\\Users\\User\\sahi\\userdata\\scripts\\tryharder\\goodoffers.txt");

    seems to be missing a quote

    _setFile(_file("file1"), "C:\\Users\\User\\sahi\\userdata\\scripts\\tryharder\\goodoffers.txt");
  • Ah I overlooked that: now I'm getting the Proxy_Fwd: appended_strings = NULL error again.

    Also the sahi console says the following
    Feb 22, 2012 10:33:34 AM net.sf.sahi.command.FileUpload appendFiles
    WARNING: net.sf.sahi.util.FileNotFoundRuntimeException: java.io.FileNotFoundExce
    ption: C:\Users\Ussr\sahi\userdata\scripts\tryharder\goodoffers.txt (The system
    cannot find the path specified)
            at net.sf.sahi.util.Utils.readFile(Utils.java:188)
            at net.sf.sahi.util.Utils.readFile(Utils.java:167)
            at net.sf.sahi.command.FileUpload.appendFiles(FileUpload.java:83)
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
            at java.lang.reflect.Method.invoke(Unknown Source)
            at net.sf.sahi.command.CommandExecuter.execute(CommandExecuter.java:55)
            at net.sf.sahi.command.MockResponder.getResponse(MockResponder.java:64)
            at net.sf.sahi.ProxyProcessor.handleDifferently(ProxyProcessor.java:164)
    
            at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:144)
            at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
            at java.lang.Thread.run(Unknown Source)
    Caused by: java.io.FileNotFoundException: C:\Users\Ussr\sahi\userdata\scripts\tr
    yharder\goodoffers.txt (The system cannot find the path specified)
            at java.io.FileInputStream.open(Native Method)
            at java.io.FileInputStream.<init>(Unknown Source)
            at net.sf.sahi.util.Utils.readFile(Utils.java:185)
            ... 12 more
    

    And I know the file is at that path.
  • I'm still having this issue if anyone can please assist.
  • narayannarayan Administrators
    Hmm, if you are a tester and you are comfortable with english, you should really be reading the error message which says:

    WARNING: net.sf.sahi.util.FileNotFoundRuntimeException: java.io.FileNotFoundExce
    ption: C:\Users\Ussr\sahi\userdata\scripts\tryharder\goodoffers.txt (The system
    cannot find the path specified)

    The file path is incorrect. :)

    Regards,
    Narayan
Sign In or Register to comment.