18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
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.
How should I debug the _readFile function failure?
I have two files a.txt and b.txt and they have different contents. _readFile can return content of a.txt but not for b.txt - looks like the content of b.txt breaks the _readFile function. There is no error and exception but just got NULL. I tried to look for log files of Sahi but there is no .log files under Sahi home directory. I found log.properties file under userdata directory and it points the log files to /tmp but I still cannot see the log files. So I specify '-Djava.util.logging.config.file' for java command and again I still cannot get log files. Could you please let me how should I troubleshoot this problem? Thanks.
Comments
I tried using % in the file and it works fine for me.
Could you please let me know how you are using _readFile() API for both the files.
Also, could you post the content of the txt file here to help us reproduce the behaviour?
Regards
Sumitra
var content=_readFile(filePath);
if(content==null){
_log("Cannot load content from "+filePath,"error");
}
And the file content is just: name=test % test . The file encoding is UTF-8 -- I am not sure if it does matter or not.
Thank you for looking into this. I am using the latest open source version.
The code should be:
var $content=_readFile($filePath);
if($content==null){
_log("Cannot load content from "+$filePath,"error");
}
Check if this solves your issue.
Also, even if the file encoding is UTF-8 Sahi will read % character from a file.
Regards
Sumitra
Yes,i m using the Sahi V3.5 version.
Could you please check if you are placing the file in non accessible directory?
Are a.txt and b.txt in the same directory?
Also, the following code works fine for me :
The testReadFile.txt contains : test % name
Regards
Sumitra
=======================
<browser>
function readFileTest(){
var $filepath = "/tmp/testReadFile.txt";
var $content=_readFile($filepath);
if($content!=null){
_log("File contents is: " + $content,"info");
}else{
_log("Failed to read file","error");
}
}
</browser>
_call(readFileTest());
Yes, even i am able to reproduce the same.
If you want to read a file which is on server you can use _readURL() API or else use _readFile() API.
Regards
Sumitra