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.
Call a specific function
Hi,
I just want to call a specific function from another script. I have used _include(). But its calling all the functions from that script.
Below is my script.
_include("C:\Documents and Settings\Arun.B\sahi_pro\userdata\scripts\InitiateTransaction.sah");
LoginAndValidation();
>>>> This function is from another script.
Delivery();
BankDetails();
//AttachFile();
NullAttachment();
function NullAttachment(){
_click(_imageSubmitButton("Submit"));
_assertExists(_span("ctl00_cphClientBody_uctlModalPopup_lblMessage"));
_click(_button("OK[1]"));
_click(_imageSubmitButton("Submit"));
}
function AttachFile(){
_click(_checkbox("ctl00\$cphClientBody\$chkAttachFile"));
_click(_imageSubmitButton("Submit"));
_assertExists(_span("ctl00_cphClientBody_uctlModalPopup_lblMessage"));
_click(_button("OK[1]"));
_setFile(_file("BrowseFile"), "C:/Documents and Settings/Arun.B/sahi_pro/userdata/New.txt");
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("BrowseFile").outerHTML = _file("BrowseFile").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("BrowseFile").type = "text");
}
// Set the value into the textbox
_setValue(_textbox("BrowseFile"), "C:/Documents and Settings/Arun.B/sahi_pro/userdata/New.txt"); _assert(_radio("ctl00_cphClientBody_ucFileUpload_rblView_0").checked);
_Click(_imageSubmitButton("Save and stay"));
}
And so on...............
Pls Help.
I just want to call a specific function from another script. I have used _include(). But its calling all the functions from that script.
Below is my script.
_include("C:\Documents and Settings\Arun.B\sahi_pro\userdata\scripts\InitiateTransaction.sah");
LoginAndValidation();
>>>> This function is from another script.
Delivery();
BankDetails();
//AttachFile();
NullAttachment();
function NullAttachment(){
_click(_imageSubmitButton("Submit"));
_assertExists(_span("ctl00_cphClientBody_uctlModalPopup_lblMessage"));
_click(_button("OK[1]"));
_click(_imageSubmitButton("Submit"));
}
function AttachFile(){
_click(_checkbox("ctl00\$cphClientBody\$chkAttachFile"));
_click(_imageSubmitButton("Submit"));
_assertExists(_span("ctl00_cphClientBody_uctlModalPopup_lblMessage"));
_click(_button("OK[1]"));
_setFile(_file("BrowseFile"), "C:/Documents and Settings/Arun.B/sahi_pro/userdata/New.txt");
// Change the "type" attribute of file field
if (_isIE()){
_call(_file("BrowseFile").outerHTML = _file("BrowseFile").outerHTML.replace(/type=file/, "type=text"));
}else{
_call(_file("BrowseFile").type = "text");
}
// Set the value into the textbox
_setValue(_textbox("BrowseFile"), "C:/Documents and Settings/Arun.B/sahi_pro/userdata/New.txt"); _assert(_radio("ctl00_cphClientBody_ucFileUpload_rblView_0").checked);
_Click(_imageSubmitButton("Save and stay"));
}
And so on...............
Pls Help.
Comments
please use the search function and check if this resolves your issue
http://sahi.co.in/forums/viewtopic.php?id=3336
http://sahi.co.in/forums/viewtopic.php?id=2902
http://sahi.co.in/forums/viewtopic.php?id=2708
http://sahi.co.in/forums/viewtopic.php?id=1943
....
but i cant find a solution for this. Pls help...
Thnx
alert.sah: and
callGreet.sah
please create these two files and then run callGreet.sah with the sahi controller. The function will be called only once (at least it should)
then compare this setup with the files you created and see if there is any difference. Note that if you called the function in file1, it will be executed when included.
This will call the function twice:
alert.sah: and
callGreet.sah
The _include function is wrkg fine. But wt the pblm is, i can't call a specific Function which i need to run. Simply it calls all functions created in the 1st script.
Thnx.