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.

BUG detected (see 3rd) Is there a way to know if errors are on the way

PachatPachat Members
edited January 2011 in Sahi - Open Source
In scripts, I use asserts because it is the normal way to write test and well supported by Sahi and well rendered in the report.

In one script I have two parts which run one after the other automatically.
But I'd like to make some decision after the first part, for instance to stop if some asserts where false.

Are there some global variables we can test telling whether at the current point some errors are already present? for example something that could be retreive along with _sessionInfo() or alike
--

Also, I tried
try{
    _assertContainsText("some missing text", document.body);
}catch(e){
    _alert('caught');
}

Why is the error never caught? I thought that _asserts where throwing exceptions?

Comments

  • PachatPachat Members
    edited January 2011
    I never got an answer on this one.

    I really need to know while the srcipt is running if some asserts where not true.
    How can I put the result of an assert in a variable and have an "if" on that variable ?

    May be simple, but after trying different things I do not know where to go.

    The assert is on wether a "phrase" is present or not on the page.
    If present, I do action A, if not, I do action B.
    Could some one help me on that ?
  • PachatPachat Members
    edited January 2011
    The reason I was struggling is probably due to what appears to be a bug :

    In my first script, I have
    _assertContainsText(document.body, "Message");
    var $res = _condition(_containsText(document.body, "Message"));
    
    The first line appears in green in the log
    The second in red in the log.

    Now, I revert the two lines :
    var $res = _condition(_containsText(document.body, "Message"));
    _assertContainsText(document.body, "Message");
    
    In the log, the first line is no more red, it is blank
    In the log, the second is no more green, it is red

    Why ?
Sign In or Register to comment.