Forum Discussion

sjordan's avatar
sjordan
Occasional Contributor
12 years ago

Stop on Specific Error

While running my tests, I generally do not want TestComplete to stop running on any errors; therefore, I have "Stop on Error" disabled in the playback options.  However, there is one particular checkpoint after which I want the test to stop running immediately if it fails.  If it continues after that failure, it could trigger the wrong process.  Are there any single commands that will make my test stop if it fails a specific checkpoint?  Thank you!
  • jose_pita's avatar
    jose_pita
    Super Contributor
    Hi Sabrina,



    You can go to the events file and add an event handler for the OnLogError event.



    On the script that controls the event you can check the priority of the error.



    Now, I use this to stop the test if the priority is bigger than 300 (mostly it happens when TC can't find an object), but for your case, you need to change the priority of that checkpoint (wich I dont know how) or do it by script with an if and a log.error(priority=400 for example).



    If this is what you want and can't do it, please tell me and I'll give you the code.



    Hope it helps
  • jose_pita's avatar
    jose_pita
    Super Contributor
    I only have code in JScript, If any one else knows how to do it in VB please help.



    This code you put on the event handler script:




    var TimeoutValue;


    var TimeoutValueDefault;


    var browser;


    var page;


     


    function GeneralEvents_OnLogError(Sender, LogParams)


    {


      if(browser.Exists === true)


        Log.Picture(browser.Page("*").PagePicture())


      else


        Runner.Stop(true);


      


      if(LogParams.Priority >300)


      {


        Runner.Stop(true);    


      }


    }



    On the test you are running, instead of the checkpoint you can put something like:



    if(object.property != something)

       log.error()//you can set an higher priority on the error menu or by script



    Anything you don't understand let me know.

  • sjordan's avatar
    sjordan
    Occasional Contributor
    Hi Jose, I believe that is exactly what I need, but my scripting skills are limited.  My project is VB.  If you have any code to manually set the error level, I would be very grateful.  I am comfortable with including scripts in my tests, I have several others, I'm just not sure how to write this one.  Thank you!