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.

Generating report for failed status

BhavithaBhavitha Members
edited November -1 in Sahi - Open Source
Hi,
with reference to the below post ,

http://sahi.co.in/forums/viewtopic.php?id=138

I tried to generate the report into a text file, it works but only for pass scripts.
the scripts which are failed, their status is not updated in the text file.

Please advice...

Comments

  • Hi Bhavitha,

    The function onScriptEnd() should work same for both success and failure.It should update the text file with scriptname and script status.Can you post the script here,So that we can find,where it went wrong.

    Regards
    Theeran.
  • Hi Theeren

    I have used the same function as defined in the post which is as below

    function end()
    {

    var $out=_scriptName() +" : "+ _scriptStatus() +"\r\n";
    _writeToFile($out,"C:\\Documents and Settings\\bsundharesan.APAC\\Desktop\\output.txt",false);

    }

    And the failed script shows error as:- Reference error: $varname is not defined.
    This script is not being updated with the failed status
  • Hi Bhavitha,

    The code should be:
    function onScriptEnd()
    {
    var $out=_scriptName() +" : "+ _scriptStatus() +"\r\n";
    _writeToFile($out,"C:\\Documents and Settings\\bsundharesan.APAC\\Desktop\\output.txt",false);
    }
    

    Here the function onScriptEnd() will be called automatically at the end of a script (even if there are errors in the script and the script stops in the middle).

    Regards
    Sumitra
  • Hi Sumitra,

    Thank you for the reply, i got the point where i was wrong.
    And i have used the same code, but do not know why the status for the passed scripts are showing duplicate times. For the failed scripts it shows one status with Failure, but the scripts which are passed are showing twice like below
    abc.sah : SUCCESS
    abc.sah : SUCCESS
    demo.sah : FAILURE
    efg.sah : SUCCESS
    efg.sah : SUCCESS

    function onScriptEnd()
    {
    var $out=_scriptName() +" : "+ _scriptStatus() +"\r\n";
    _writeToFile($out,"C:\\Documents and Settings\\bsundharesan.APAC\\Desktop\\output.txt",false);
    }
    onScriptEnd();


    Please advice.

    Thankyou
  • narayannarayan Administrators
    Hi Bhavitha,

    You have called onScriptEnd(); at the end.
    This need not be explicitly invoked.
    Sahi will automatically call onScriptEnd() when it finishes. onScriptEnd() is a callback function that Sahi checks and calls when a script finishes.

    So, delete the onScriptEnd(); in your code.

    Regards,
    Narayan
  • Hi Narayan,

    Ya now its working fine..
    Thanks a lot!!
This discussion has been closed.