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.

The return in custom functions

MikeSMikeS Members
edited November -1 in Sahi - Open Source
Hi.

Does Sahi support return in all custom functions or only in <browser>-ones?
I need to use my function, which returns the value, but it's not the <browser> one and I get the error that this function is not defined.

Thanks.

Comments

  • MikeSMikeS Members
    To clarify the situation:

    I am using FCKEditor on the page and I need to get-and-set its value.
    My custom functions are:
    <browser>
    function fckEditorGetValue($id)
    {
        return FCKeditorAPI.GetInstance($id).GetHTML();
    }
    
    function fckEditorSetValue($id, $value)
    {
        FCKeditorAPI.GetInstance($id).SetHTML($value);
    }
    </browser>
    

    As long as they are <browser>-ones, I cannot use them just like that:
    fckEditorSetValue('description', 'description test');
    fckEditorGetValue('description');
    
    but I can with something like that:
    _setGlobal('qweqweqweqw', fckEditorSetValue('description', 'description test') );
    
    where 'qweqweqweqw' is just the name of some useless global key.


    If I remove <browser>, I am not able to user return in get function.

    What shall I do?
  • narayannarayan Administrators
    For browser functions, you need to fetch the value from the browser using _set.

    Do

    var $html = null;
    _set($html, fckEditorSetValue('description', 'description test'));

    Regards,
    Narayan
  • MikeSMikeS Members
    Thanks a lot, that was not obvious.
    So, I cannot use return in non-browser functions?
  • narayannarayan Administrators
    Hi Mike,

    My mistake. My answer must have made it more unclear!
    You can return values and my example should have looked like this:

    To explicitly retrieve value from a browser function

    var $html = null;
    _set($html, fckEditorGetValue('description'));
    _alert($html)


    To explicitly call a browser function:

    _call(fckEditorSetValue('description', 'description test'));


    Regards,
    Narayan
Sign In or Register to comment.