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.

Write File

orbaraorbara Members
edited November -1 in Sahi - Open Source
Hellow,

Running the script, I must generate a file with different times of the Sahi's script.
I have see that a solution to write a file is using _debugToFile
_debugToFile(

Comments

  • narayannarayan Administrators
    orbara,

    _debugToFile should have worked for you. Did you see any exception on the Sahi console?

    Using ActiveXObject will not work since Sahi uses Rhino as its javascript engine, which does not understand ActiveXObjects (ActiveXObject are only supported by IE).

    You can use java to write to a file if you want. Eg.
    function writeToFile($message, $filePath){
      var out = new java.io.FileWriter($filePath, true);
      out.write($message + "\n");
      out.close();
    }
    
    writeToFile("my message", "d:/temp/sahi_debug.log");
    
  • orbaraorbara Members
    Thank you very much
  • I tried the code suggested by Narayan. I wish to write the results of a test case to a text file. But after the test runs, the file is blank. the _writeFile() doesn't seem to be working either.
  • Hi hishamn,

    The code should be:
    var $ar = new Array();
    $ar[0] = ["hi", "there", "one"];
    $ar[1] = ["hey", "he" , "she"];
    _writeCSVFile($ar, "D:/sample.csv", true, ",");
    

    Let me know if this solves your issue.

    Regards
    Sumitra
  • I'm sorry but i this did not seem to make a difference. The file was still blank when i opened it. Nothing was written.
  • Hi hishamn,

    Closing this thread as it is been solved in another thread.

    Regards
    Sumitra
This discussion has been closed.