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 to call another sahi file in current executing sahi file
Hi All,
i am new to sahi, can any 1 guide me how to call user defined functions which is existing in another sahi file
Example:
there is 2 sahi files
1. "Functions.sah" containing add() function in this file
2. "Business.sah"
Now i wanna call "add()" function in "Business.sah" file
pls guide me how to call user defined functions which are existing in one file and i wanna call those functions in another sahi file
Thanks in advance
i am new to sahi, can any 1 guide me how to call user defined functions which is existing in another sahi file
Example:
there is 2 sahi files
1. "Functions.sah" containing add() function in this file
2. "Business.sah"
Now i wanna call "add()" function in "Business.sah" file
pls guide me how to call user defined functions which are existing in one file and i wanna call those functions in another sahi file
Thanks in advance
This discussion has been closed.
Comments
You can use _include("includes/common_functions.sah");
For more Details:
http://sahi.co.in/w/_include
Regards
Sumitra
thanks for your reply
i followed the way which u have posted but it's showing an error like below
_alert(wish("siva"));
ReferenceError: wish is not defined
ReferenceError: wish is not defined
at [object Object]. (eval at h t t p: / / www . google . co . in/_s_/spr/concat.js:3016:14)
at [object Object].ex h t t p: / / www . google . co . in/_s_/spr/concat.js:3016:9
at unknown source
the 2 files which i have created is shown below, pls let me know if there is any mistake which i have followed
File Name: Functions.sah
******************************************************************************
function wish($str){
return "Hi"+ $str;
}
******************************************************************************
File Name: sample.sah
******************************************************************************
var $filePath = "C:/Documents and Settings/gaveyom/sahi/userdata/scripts/demo/includes/Functions.sah";
_include($filePath);
_alert(wish("gaveyom"));
******************************************************************************
pls change your script to but please don't ask my why this is needed
something like... broser.. proxy.. variables and functions... there is some difference.. somewhere, that's why the browser tags are needed.. see http://sahi.co.in/w/sahi-script-and-javascript for details
Regards
Wormi
thanks for your reply
i followed the way which u have posted but it's showing an error like below
Error message which i got
******************************************************************************
_alert(wish("siva"));
ReferenceError: Can't find variable: wish
No trace available
******************************************************************************
the 2 files which i have created is shown below, pls let me know if there is any mistake which i have followed
File Name: Functions.sah
******************************************************************************
<browser>
function wish($str){
return "Hi"+ $str;
}
</browser>
******************************************************************************
File Name: sample.sah
******************************************************************************
var $filePath = "C:/Documents and Settings/gaveyom/sahi/userdata/scripts/demo/includes/Functions.sah";
_include($filePath);
_alert(wish("gaveyom"));
*****************************************************************************
Congratulations, you may have found a bug
While
_include( "C:/Documents and Settings/gaveyom/sahi/userdata/scripts/demo/includes/Functions.sah");
works.....
var $filePath = "C:/Documents and Settings/gaveyom/sahi/userdata/scripts/demo/includes/Functions.sah";
_include($filePath);
does not.
So the workaround is to not use variables for including
amazing, its working
thanks a lot globalworming
u r right, if we mention the path directly instead of using variable then it is working
one more thing i noticed that we can write functions with out using <browser> option also
******************************************************************************
<browser>
function wish($str){
return "Hi"+ $str;
}
</browser>
******************************************************************************
OR
******************************************************************************
function wish($str){
return "Hi"+ $str;
}
******************************************************************************
both ways are working for me
Just for information.It is not a bug.
In _include(filepath);
The path can be absolute file path or a path relative to the file where the script is included.
Regards
Sumitra