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.
Read value from file
My Os=Linux
Browser=firefox
add one function in file and get value of customer variable from text file
my Program file like :
function match($user)
{
var $content = _readFile("/usr/local/Sahi/userdata/scripts/text.txt");
var $lines = new Array();
$lines = $content.split("\n");
for (var $i = 0; $i < $lines.length; $i++){
if ($lines[$i].match($user)){
var $x = $lines[$i].split("=");
_log($x[1],"debug");
return $x[1];
}
}
return "Not Found";
}
var $out;
_set($out,match("customer"));
_log($out,"info");
My text file is like this
customer=1000
I want output 1000
i got ouput 1000 when i am calling the function like match("customer");
but when i called function like _set($out,match("customer")); , in that i want to store return value from function in out variable ,but in that i got error in log file that i mention below
_sahi.setServerVar('\$out', match("customer"));
ReferenceError: match is not defined
Browser=firefox
add one function in file and get value of customer variable from text file
my Program file like :
function match($user)
{
var $content = _readFile("/usr/local/Sahi/userdata/scripts/text.txt");
var $lines = new Array();
$lines = $content.split("\n");
for (var $i = 0; $i < $lines.length; $i++){
if ($lines[$i].match($user)){
var $x = $lines[$i].split("=");
_log($x[1],"debug");
return $x[1];
}
}
return "Not Found";
}
var $out;
_set($out,match("customer"));
_log($out,"info");
My text file is like this
customer=1000
I want output 1000
i got ouput 1000 when i am calling the function like match("customer");
but when i called function like _set($out,match("customer")); , in that i want to store return value from function in out variable ,but in that i got error in log file that i mention below
_sahi.setServerVar('\$out', match("customer"));
ReferenceError: match is not defined
This discussion has been closed.
Comments
Instead of
var $out;
_set($out,match("customer"));
Just use
var $out = match("customer");
Regards,
Narayan
Have a look at: http://sahi.co.in/w/_set
Regards,
Narayan