cancel
Showing results for 
Search instead for 
Did you mean: 

Data Driven Loop - Next iteration when an errors occurs

SOLVED
Highlighted
New Contributor

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...

1 ACCEPTED SOLUTION

Accepted Solutions
Community Hero

Re: Data Driven Loop - Next iteration when an errors occurs

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


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

8 REPLIES 8
Community Hero

Re: Data Driven Loop - Next iteration when an errors occurs

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.

New Contributor

Re: Data Driven Loop - Next iteration when an errors occurs

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

 

New Contributor

Re: Data Driven Loop - Next iteration when an errors occurs

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

Community Hero

Re: Data Driven Loop - Next iteration when an errors occurs

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.

 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
New Contributor

Re: Data Driven Loop - Next iteration when an errors occurs

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.

 

Community Hero

Re: Data Driven Loop - Next iteration when an errors occurs

As mentioned, this way of writing tests is best practice: check for existance before using the object if there is doubt.  So, making the change all around is necessary re-factoring. 

There's no "generic" child object because you need to specify what object you're waiting for to exist... you can't just say "wait for an object"... which object?


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
New Contributor

Re: Data Driven Loop - Next iteration when an errors occurs

I am surprised that there is not a solution like the try / catch for this type of error.

Community Hero

Re: Data Driven Loop - Next iteration when an errors occurs

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


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available

View solution in original post

New Here?
Join us and watch the welcome video:
Watch the new Interview
Top Kudoed Authors