how to continue to next Data-Driven loop item on error
SOLVED- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
how to continue to next Data-Driven loop item on error
Now i am testing a windows application, record the create new customer operation, need to read data from excel and enter the input fields. And i am using the Data Driven Loop to run multiple test cases, TestComplete will stop on error if there exists error, so i want to know how to continue to next Data-Driven Loop item.
Solved! Go to Solution.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Under the 'Tools > Current Project Properties' menu,
click on 'Playback' in the left navigation
uncheck the 'Stop on Error' checkbox under the 'Runtime' section.
Then it will display the error in Log and will move to next test item.
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Shankar R,
Thanks for your reply, but my question is how to move to next Data-Driven Loop item, if there any one step under Data-Driven Loop failure, i want to skip the rest steps and move to next Data-Driven Loop item.
Thanks
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
If you are using Script data-driven loop then you can use try catch to ignore the current iteration error like below,
For example:
function Main() { Driver = DDT.ExcelDriver("../../TestBook.xlsx", "TestSheet", true) TestedApps.RunAll(); orders = Aliases.Orders; mainForm = orders.MainForm; while(!Driver.EOF()) { try { OpenForm(); orderForm = orders.OrderForm; groupBox = orderForm.Group; PopulateForm(); Checkpoint(); CloseForm(); } catch(ex) { Log.Error("Error in loop"); } Driver.Next(); } CloseApplication(); }
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am not using Script data-driven loop, if there any method to resolve data-driven loop. By the way, because i just using python, can you change the Script to Python. Thanks a lot.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I'm not pythonic 🙂 but i just tried
def Main(): Driver = DDT.ExcelDriver("../../../TestBook.xlsx", "TestSheet", True) TestedApps.RunAll() orders = Aliases.Orders mainForm = orders.MainForm while not Driver.EOF(): try: OpenForm() orderForm = orders.OrderForm groupBox = orderForm.Group PopulateForm() Checkpoint() CloseForm() except: Log.Error("An error occurred.") Driver.Next() CloseApplication()
Referred here:
https://docs.python.org/3/tutorial/errors.html
Thanks
Shankar R
LinkedIn | CG-VAK Software | Bitbucket | shankarr.75@gmail.com
“You must expect great things from you, before you can do them”- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi there,
I'm trying the same thing as Hardy but my script won't continue with the next loop item. I tried it with the "stop on error" setting enabled or disabled, but in both cases my script doesn't execute the keyword test I'd like to run in the except.
I'd appreciate any help
Regards, David
My script:
def VA_Test(): Project.Variables.VA_Test_Parameter.Reset() while not Project.Variables.VA_Test_Parameter.IsEOF(): try: KeywordTests.Login.Run() KeywordTests.MMS100_VerteilauftragErstellen.Run() Delay(40000, "wait") KeywordTests.MMS100_VARuestrueckmeldung.Run() KeywordTests.MMS100_VA_RuestenKorrigieren.Run() KeywordTests.Logoff.Run() except: KeywordTests.CleanUp.Run() finally: Project.Variables.VA_Test_Parameter.Next()
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Keep in mind that try/except/finally logic will only catch actual raised exception errors like Python syntax, etc. If the keyword tests within your try block simply generate an error like "Log.Error" or a checkpoint that fails with an error message, these won't be trapped by try/except logic. What you should do, in order to utilize the logic as you have, is to raise exceptions (in JavaScript it's "throw Error(<message>)") instead of simply logging errors. That will then trigger your try catch logic.
Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for your answer.
On the one hand I understand now why it didn't work the way I tried to do it, but on the other hand I still can't make it work.
I think I understood the concept of what your're trying to explain, but I don't really know how to throw/raise the error.
Would it be possible to use an OnLogError-EventHandler in order to raise the python exception? Could I catch such an exception with the script I posted above?
Regards, David
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The with statement in Python simplifies exception handling by encapsulating common preparation and clean-up tasks in so-called context managers. This allows common try..except..finally usage patterns to be encapsulated for convenient reuse and reduce the amount of code you need to write for handling different kinds of exceptions. The with statement creates resources within a block . You write your code using the resources within the block. When the block exits the resources are cleanly released regardless of the outcome of the code in the block (that is whether the block exits normally or because of an exception).
