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.

How can we access variables from a script included in another script?

hbabbarhbabbar Members
edited July 2013 in Sahi - Open Source
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");


Answers

  • Hi Himanshu,
    Are Login.sah and ReadCsv.sah in the same folder?

    If yes, your script should work perfectly fine.

    If not, you would have to provide the relative path of ReadCsv.sah with respect to Login.sah in the include statement.

    e.g. if "Login.sah" is in "sahi/userdata/scripts" folder and ReadCsv,sah is in "sahi/userdata/scripts/a" folder,
    your include line would be:
    _include("/a/ReadCsv.sah");
    

    Similarly, if "Login.sah" is in "sahi/userdata/scripts/a" folder and ReadCsv.sah is in "sahi/userdata/scripts" folder,
    your include line would be:
    _include("../ReadCsv.sah");
    

    It should work for you this way.

    Regards.
Sign In or Register to comment.