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.

_include inside a function

lonely_girl01lonely_girl01 Members
edited November -1 in Sahi - Open Source
Hi,

Is it possible to use _include inside a function?
'Cause when i tried, it doesn't work.


Thanks and regards.

Comments

  • narayannarayan Administrators
    Hi,

    _include expands the script in place, before the execution starts. It is a simple string substitution. If your function and included file are well formed it will work correctly. You can look at the "Parsed Script" link on the Controller Playback tab to see how the include works.

    That said, it is better to have includes at the top of a script. Let us say A includes B. Then instead of including B conditionally inside a function, include B at the top of A, but keep the code in B inside functions and then call the functions at the appropriate places in A.

    Hope that helps.
    Regards,
    Narayan
  • Hi Narayan,

    Right. Got it.

    One more thing.
    I think, _include doesn't read a variable?
    I have my code like this:
    var $fileName = $drive_path + "filename.sah";    
    _include($fileName);
    



    Thanks and regards.
  • narayan wrote:
    _include expands the script in place, before the execution starts.

    The variable is empty.. or it might be more valid to say, that it isn't even recognized as a variable.
  • narayannarayan Administrators
    Yes, as Wormi says, when the _include is processed, the whole script is just seen as a string. It is not yet being interpreted as javascript, so the variable name will not work.

    Regards,
    Narayan
  • Thanks for the help guys.
    I fully understand _include now. :)
Sign In or Register to comment.