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.

Test name

beemanbeeman Members
edited November -1 in Sahi - Open Source
How is the executing test name accessed? For example, a test freezes on a CI server and a screen images is created with the name of the executing test.

Comments

  • Hi beeman,

    You can use _scriptName() API with callback functions.

    Here is an example:
    function onScriptFailure(){
        _alert(">> In onScriptFailure");
        var $name = _scriptName();
        _alert($name);
    }
    _navigateTo("http://sahi.co.in/demo/training/");
    _setValue(_textbox("user"), "test");
    _setValue(_password("password"), "secret");
    _click(_submit("Login"));
    _assertExists(_submit("Login")); // cause SCRIPT ASSERTION FAILURE - triggers onScriptFailure
    _setValue(_textbox("q[1]"), "1");
    _setValue(_textbox("q[2]"), "1");
    _click(_button("Add"));
    _click(_button("Logout"));
    

    Other callback functions are:

    onScriptError();

    onScriptEnd();

    Let me know if this solves your issue.

    Regards
    Sumitra
  • Sumitra:

    Thanks for the reply. _scriptName() is almost what I what. For example,

    scriptName.sah contains

    function testName1() {}

    function testName2() {}

    Is it possible to get test name (testName1, testName2) that was running when there was an exception?
Sign In or Register to comment.