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 can we access variables from a script included in another script?
Hi
I have a script that includes another script that has common functions and methods. I need to access the variable defined in one script into the other. How can i do this?
Here is the structure of the script.
Login.sah
_include("ReadCsv.sah");
//line 2
// line 3
_log($csvData[0][1]); // I need to access $csvData from ReadCsv.sah
ReadCsv.sah
var $csvData = __readCSVFile("C:\\Users\\Desktop\\Sahi Pro\\Data.csv");
I have a script that includes another script that has common functions and methods. I need to access the variable defined in one script into the other. How can i do this?
Here is the structure of the script.
Login.sah
_include("ReadCsv.sah");
//line 2
// line 3
_log($csvData[0][1]); // I need to access $csvData from ReadCsv.sah
ReadCsv.sah
var $csvData = __readCSVFile("C:\\Users\\Desktop\\Sahi Pro\\Data.csv");
Best Answer
-
perhaps have a "driver" type script - that will couple the 2 :
function in file 1 : a.sah
function a(){
// some stuff
a = 1 + 1;
return a;
}
function in file 2 : b.sah
function b(a){
// some stuff
b = 1 + a;
return b;
}
The Driver script :
_include("a.sah");
_include("b.sah");
var $a = function a();
$answer = function b($a);
_alert($answer);
as you can see - you return and set the variable outside your main script - giving it almost a"global" level.
you can then use this in other functions across scripts, if they are included in the file.
so to summarize :
write individual functions to get and return variables.
Use a "driver" file or wrapper class to combine and include the functions.
pass the functions "at a global level" to each other.
Answers