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.

Getting SAHI_ERROR while trying to upload a file

DeekshaDeeksha Members
edited November -1 in Sahi - Open Source
Hi,

I am getting SAHI_ERROR while trying to upload a file.

Script: _setFile(_file("uploadedFile"), "C:\\temp\\Testing.txt");

Result in Sahi console:

command: FileUpload_appendFiles
6 Feb, 2012 2:52:23 PM net.sf.sahi.command.FileUpload appendFiles
INFO: Uploading: fileName = resolved to C:\Users\deeksha.goyal\sahi\userdata
6 Feb, 2012 2:52:23 PM net.sf.sahi.command.CommandExecuter execute
WARNING: commandClass = >net.sf.sahi.command.FileUpload< commandMethod = >append
Files<
6 Feb, 2012 2:52:23 PM net.sf.sahi.command.CommandExecuter execute
WARNING: java.lang.reflect.InvocationTargetException
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 net.sf.sahi.ProxyProcessor.processConnect(ProxyProcessor.java:183)
at net.sf.sahi.ProxyProcessor.processAsProxy(ProxyProcessor.java:142)
at net.sf.sahi.ProxyProcessor.run(ProxyProcessor.java:93)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source
)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.sahi.util.FileIsDirectoryException
at net.sf.sahi.util.Utils.readFile(Utils.java:180)
at net.sf.sahi.util.Utils.readFile(Utils.java:167)
at net.sf.sahi.command.FileUpload.appendFiles(FileUpload.java:83)
... 15 more

Please suggest me.

Thanks

Comments

  • Hi Deeksha,

    INFO: Uploading: fileName = resolved to C:\Users\deeksha.goyal\sahi\userdata

    The file seems to be resolved to userdata directory.There has been a change in the way paths are resolved.

    Now _setFile paths will be resolved relative to userdata directory, so that you can keep all scripts, upload files etc. in a single place (ie. within userdata dir).Can you post the script?

    Why not try with _setFile("yourFileField", "youUploadFile","yourSubmitURL"); ? Make sure that no parameters are left with null values("").

    This might help you.

    Regards,
    Theeran.
  • Thanks for the reply!

    I tried both the solutions but situation is still the same, as soon as i click on send button, it gives SAHI_ERROR on page.

    Following is the script:

    _include("0TXSenderlogin.sah");
    ActasSender();
    _click(_link("Batch Management"));
    _click(_link("Send a batch of documents to a trading partner"));
    _setSelected(_select("docType"), "Invoice");
    _setFile(_file("uploadedFile"), "");
    _setFile(_file("uploadedFile"), "Testing.txt");
    _click(_checkbox("allowDuplicates"));
    _click(_link("Send[1]"));
    _click(_link("OK"));

    Thanks,
    Deeksha
  • Hi Deeksha,

    Delete all script that value is ""
    like _setFile(_file("xxxxx"), "");

    not
    _setFile(_file("uploadedFile"), "");
    _setFile(_file("uploadedFile"), "Testing.txt");

    but
    _setFile(_file("uploadedFile"), "Testing.txt");

    This might help you.

    Regards,
    Theeran.
  • That Doesn't make any difference, problem is still the same.
  • Hi Deeksha,

    Hope you have removed _setFile(_file("uploadedFile"), ""); from the script.

    If you are still getting the error, kindly check if you are getting any error on Sahi console and post the content of it. Can you also post the script too?

    Regards,
    Theeran.
Sign In or Register to comment.