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.
writeFile with Global variables
Hi,
When i am trying to use writeFile with getGlobal it is now working.
The mentioned file is present in the path and when i try ro append some test on it, it is now working.
_setGlobal("LogFile","C:\\Log_01Oct20.log");
_alert(_getGlobal("LogFile"));
_writeFile("Testing Attention Please\r\n" ,_getGlobal("LogFile"));
Error Message:
JSERROR Wrapped java.lang.NullPointerException
However when i use this: _writeFile("Testing Attention Please\r\n" ,"C:\\Log_01Oct20.log") its working.
When i am trying to use writeFile with getGlobal it is now working.
The mentioned file is present in the path and when i try ro append some test on it, it is now working.
_setGlobal("LogFile","C:\\Log_01Oct20.log");
_alert(_getGlobal("LogFile"));
_writeFile("Testing Attention Please\r\n" ,_getGlobal("LogFile"));
Error Message:
JSERROR Wrapped java.lang.NullPointerException
However when i use this: _writeFile("Testing Attention Please\r\n" ,"C:\\Log_01Oct20.log") its working.
Tagged:
This discussion has been closed.
Comments
_debugToFile("Testing" ,_getGlobal("LogFile"));
Some statements
_debugToFile("Attention" ,_getGlobal("LogFile"));
Some more statements
_debugToFile("Please\r\n" ,_getGlobal("LogFile"));
1) The variable will be accessible even in included B, since included files are all flattened out into a single script by Sahi.
2) _getGlobal and _setGlobal are not very useful since Sahi V2. Just define a variable and use it the way DP suggests. If it does not work, let us know.
Regards,
Narayan
Thanks Dp & Narayn