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 to call a specific function in a file from another file

Debakanta sahuDebakanta sahu Members
edited July 2011 in Sahi - Open Source
Hi,

In my script file i use _include("count.sah");
this count.sah file contains five functions but i want to call only one function to execute.
but when i run my script file these five functions present inside the count.sah file also execute one by one.

after including the count.sah file, i call only one function like,
count_five();.but all other functions are also execute.

Regards,
Debakanta

Comments

  • SumitraSumitra Members
    Hi Debakanta sahu,

    Can you post the contents of the script count.sah?

    Regards
    Sumitra
  • Hi Debakanta,
    if you defined the functions as
    function name() {
    
    }
    
    they shouldn't execute when included. Did you do so?
  • Hi there,

    I am also facing the same problem, I need to call only one of the function from my nr_common.sah
    How can I call a particular function to other script?
  • Hi Tina,

    Can you post the contents of nr_common.sah.This problem may occur,if there is function call to all the function declared in nr_common.sah file.

    Regards
    Theeran.
  • Hi All,

    I am facing the same problem. Below i mention the scenario:
    there is sahi file (Libs.sah), this file contains lots of functions say (function1(), function2(), function3()....and lots more).
    and there is one more sahi file (CallTestCase.sah). here my query is when i execute this .sah file, i just want function2() need to be called or run from Libs.sah file. but actually i am unable to do so.

    Could anyone there please help me out and tell me about how to call a specific function in a sahi file from another sahi file?

    Regards,
    Deepak Verma
  • globalwormingglobalworming Moderators
    edited December 2011
    Hi all

    this should really be no problem, just use _include("Libs.sah") and then use function2() as you would usually do. Try to run CallTestCase.sah from the controller. Then click at "view parsed script" on the bottom of the controller. You will see that _include() will just insert your Libs.sah and will therefor make every function in Libs.sah available for CallTestCase.sah. The only problem could be a wrong path to the file, but Sahi should mention that...
  • why do not try ruby or java as the test script language?
  • narayannarayan Administrators
    I would not recommend it, given that the user does not seem to understand the difference between a function call and a function definition!
Sign In or Register to comment.