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.

How do I stop playback?

tedweatherlytedweatherly Members
edited November -1 in Sahi - Open Source
I have this script:
function Init() {
  var $entryName = "Entry 1";
  CreateEntry($entryName);
  _setValue(_textbox("field1"), "foobar 1");
  _setValue(_textbox("field2"), "foobar 2");
}

function CreateEntry($entryName) {
  if (_link($entryName) == null) {
    _click(_button("Insert"));
  } else {
    var $errorMsg = "Entry \"" + $entryName + "\" already exists";
    _stopOnError();
    try {
      _assertEqual(_link($entryName), null, $errorMsg);
      _log($errorMsg, "error");
      _log($errorMsg, "failure");
      _debugToErr($errorMsg);
    } catch (e) {
      _logExceptionAsFailure(e);
    }
  }
}

Suppose this "Entry 1" does exist on the page. I see all the correct log and debug messages but playback does not stop until the _setValue call for field1 is called (b/c field1 won't exist b/c the "Insert" button wasn't clicked). I want playback to stop inside CreateEntry(). How do I do this?

Thanks in advance!
-Ted

P.S. I'm running Sahi Build 2010-11-03 on Window 2003 Server with IE 8.

Comments

  • narayannarayan Administrators
    Hi Ted,

    _stopOnError() is a directive to Sahi to stop executing further IF there is an error. It is to toggle back the effects of _continueOnError().

    If you want to get out of the script, you could use

    _fail("some message")

    This will log the message and abort execution.

    Regards,
    Narayan
  • Perfect. Thanks Narayan.
This discussion has been closed.