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.

I need help with Sahi syntax to obtain function name

rj412rj412 Members
edited November -1 in Sahi - Open Source
/*
SOURCE
Callme();

function Callme (){

//var $funcName = arguments.callee.toString();
var $funcName = arguments.callee.caller.name.toString();
//var $funcName = document.activeElement.name.toString();

_alert($funcName);
}
*/

Whats wrong with above code?

Comments

  • narayannarayan Administrators
    Hi,

    If you want the output to be "Callme", you need

    var $funcName = arguments.callee.name;

    Regards,
    Narayan
  • thanks Narayan.
    this works; you may close this topic.

    I needed this for troubleshooting when dealing with a lot functions.
    I'm surprise this is not provided out the box for logging purposes.

    /*
    SOURCE
    */
    CallMe();

    function CallMe() {
    logFunctionName ( argument.callee.name) ;

    Call_Another_Function_2 ();
    }

    function Call_Another_Function_2 () {
    logFunctionName ( argument.callee.name) ;

    //Call_Another_Function_3 ();
    }

    /* --- Placed in Common Sah --- */
    function logFunctionName ($funcName) {
    _log("*********** " +$funcName " ************")
    }
  • narayannarayan Administrators
    Hi,

    We have been working on a solution for this.

    In the next build, errors and failures will automatically be shown with a trace of function calls.
    You can also explicitly get the stack trace using _stackTrace();

    I can send you an early release if you would like.

    Regards,
    Narayan
This discussion has been closed.