Forum Discussion

fm28's avatar
fm28
New Contributor
6 years ago

Data Driven Loop - Next iteration when an errors occurs

Hi,

 

I don't speak English so excuse me for the faults. 

 

I use the Data Driven Loop in my keyword test attached to a Excel files contains 7 columns and 30 rows. When I have a error "Object not found", I search to go to the next rows in Table Data. Not continue running when i have an error but go to the next rows.

 

I don't find the solution...

  • There is a solution - "If Object" operation for keyword tests and "WaitChild" for script code.

  • Seems like you could use try/catch inside your data driven loop for this.  If an error happens, use the catch to log it and then do nothing else so you fall through to the next iteration of the data.

    • fm28's avatar
      fm28
      New Contributor

      I tried the try/catch, but it's specified it doesn't work with this error type (They do not handle errors that are posted to the test log by TestComplete test objects, methods and properties, like “Object not found”, “Object does not support this property or method” and the like. To handle these errors, create an event handler for the OnLogError event

       

      I tried the OnLogError with no results

  • arajulapati's avatar
    arajulapati
    New Contributor

    If you are using Vb script you can use On Error Resume next or in Jscript you can use try catch block.

     

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      As mentioned, exception handling is not going to work on this.  Instead, what you're going to have to do is make your code "smarter".  For those points where object recognition is failing or similar things, you'll need to add logic to break out of the loop on those errors.  In pseudo-code:

       

      if (!Aliases.myApp.parentObject.WaitAliasChild("childObject", 5000).Exists) then

          End Loop

       

      This is actually a recommended best practice for any situation where you aren't sure that the object is going to apear in time and that object existence is part of the test.

       

      • fm28's avatar
        fm28
        New Contributor

        Thanks for the answer.

        I succeeded to pu it in place, but I'm obligated to put it on every line (about 40/50 lines). childObject isn't generic; there is no generic solution ? without specifying a childobjet ?

        The error can be everywhere, jsute because of a slow response or it was too fast.