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.

Why do the files remain blank after i try to use writefile??

hishamnhishamn Members
edited November -1 in Sahi - Open Source
Hey
i have been trying all day to write messages to a text file. But the writefile doesnt seem to work at all. the file is always blank when i open it. i tried writing to a csv file but that did not work either.
Am i missing some steps??
1)
_writeToFile("Test passed without errors","C:\Users\hishamn\sahi\userdata\scripts\TestLog.txt");
2)
var $Result= [
["Test", "Passed"],
["without", "errors"] ];


_writeToFile($Result,"C:\Users\hishamn\sahi\userdata\scripts\TestResults.csv", overwrite);

Comments

  • * _writeCSVFile($Result,"C:\Users\hishamn\sahi\userdata\scripts\TestResults.csv");
  • 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.
  • narayannarayan Administrators
    Hi Hishamn,

    Your way of declaring the data is correct, and so is Sumitra's. They are just different ways of doing the same thing.

    I guess your problem is with the slashes in the file path. Change them to forward slashes, or use double back slashes and check.

    C:/Users/hishamn/sahi/userdata/scripts/TestResults.csv
    or
    C:\\Users\\hishamn\\sahi\\userdata\\scripts\\TestResults.csv

    Regards,
    Narayan
  • Thanks, it seems to be working now :)
This discussion has been closed.