Forum Discussion

Sindu's avatar
Sindu
New Contributor
5 years ago

Return to end of the function on any error during execution of script

We have one function for calling all the functions to be executed where all functions to be executed are called via Excel.

 

As it is only one test item, one log is generated at the end. Do we have an option to split the logs for each row in excel?

 

And also, during the script execution, if the object is not found run time error occurs and error is posted in log file causing the execution to stop. And, if the entire block is enclosed in try-catch block, on run-time error the control is not passed to catch block.

 

How can we handle such situations and continue the script execution?

3 Replies

  • Wamboo's avatar
    Wamboo
    Community Hero

    ->>>>
    "We have one function for calling all the functions to be executed where all functions to be executed are called via Excel"

     

    I know that in some cases it is necessary to call functions from excel file but from experience I know that it would be better for you to switch to calling test functions by "Test Items" explorer. This really solves a lot of problems automatically.

     

    ->>>>
    "As it is only one test item, one log is generated at the end. Do we have an option to split the logs for each row in excel?"

     

    I have an idea about that:

     

    In the "OnStartTest" event, use the name of the function called from excel and then make a folder out of it using

     

    Log.CreateFolder

     

    and pack all the logs into this folder using "OnLog*" events.

    Maybe it'll help somehow, let me know.

     

    ->>>>
    "And also, during the script execution, if the object is not found run time error occurs and error is posted in log file causing the execution to stop. And, if the entire block is enclosed in try-catch block, on run-time error the control is not passed to catch block."

     

    try{

    } catch(e) {
    }

    This may not work here because it relates to the "syntax error" control of e.g. JavaScript.

     

    The error that is not "syntax error" but "internal Testcomplete error". You can handle it with the event e.g. "OnLogError".

     

    In TestComplete you can set the variable "On error" to Continue Error but this is done by the project explorer.

     

    You can do this by adding one function in the explorer -> in this function you will use the function containing the call

     

    aqObject.CallMethod;

     

    and with this you will get the names of the functions to run. This requires a little more work, but if you need help, let me know.

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > Do we have an option to split the logs for each row in excel?

    Try the aqTestCase's .Begin()/.End() methods and see if this is what you are looking for.

     

    • TanyaYatskovska's avatar
      TanyaYatskovska
      SmartBear Alumni (Retired)

      Thanks for your suggestions, Wamboo, AlexKaras!

       

      Sindu, was the issue resolved? Please share the solution you decided to use.