How to restart the current iteration of a data driven test?

Best practices, code snippets for common functionality, examples, and guidelines.
Posts: 19
Joined: Mon Jun 08, 2015 6:21 am

How to restart the current iteration of a data driven test?

Post by AdamMackintosh » Thu Jun 25, 2015 7:40 am

Hello, I have a testcase that is inputting into an html form webpage about 10 variables of data from a csv file.

Due to a network error, occaisionally, Ranorex will encounter a browser page loading error at a critical time that cannot be recovered from without closing/reopening the browser, so I would like to restart the current iteration to still input the data from the row in the csv that failed. This will work because the first step is to open the browser to the desired URL.

Is there an easy way to tell Ranorex to restart the current iteration if it fails at any point?

To clarify, iteration #7 of 40 fails and kills my test case. Can I have it automatically restart iteration #7 until it successfully passes #7 and it will not move onto iteration #8 until 7 was successfully passed?


User avatar
Ranorex Guru
Ranorex Guru
Posts: 7465
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: How to restart the current iteration of a data driven test?

Post by odklizec » Thu Jun 25, 2015 8:26 am


At some point, I too considered how to deal with occasional network/server errors, which failed my tests. Unfortunately, I found no good and reliable solution yet.

I mean, it should not be a problem to restart the test case iteration (sorry, I don't know the proper code). The problem is in what you wrote... "if it fails at any point".

This is the real problem of your request. How to detect and handle network errors at any point of test run? Adding error detection and handling code between each test step or even at start/end of each module is not an option.

I considered using code for handling unexpected dialogs, to deal also with unexpected (but known) network/server errors. The problem is, that this unexpected dialog handling code runs in second thread and there is currently no way to pause/stop the main application thread, in which runs your test.

In other words, while the unexpected window handling may catch the network/server error quite well (and at any point of test case run), there is no way to pause the test and restart it or do whatever you want to fix the test workflow. I believe I'm not alone who already requested such option (to pause main thread from dialog handling thread)? ;)
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

Posts: 19
Joined: Mon Jun 08, 2015 6:21 am

Re: How to restart the current iteration of a data driven test?

Post by AdamMackintosh » Mon Jun 29, 2015 10:37 pm

My issue is that the server gets busy during one of two popups that load during the iteration, and the browser tab simply cannot be salvaged, so I have to either 'continue on failure' which leaves a random row in my CSV file missing from the test case and also leaves an extra lingering IE browser windows open that cause issues in upcoming iterations.

When the browser detonates on me, you cannot press F5 or recover the current screen unless you open the URL in a new window/tab which loses the POST data anyway. I have no choice but to restart the whole form submission (aka the current iteration).

I've scoured the web, and it looks like the only way around it will be to manually code something, and part of that will be figuring out how to tell Ranorex to abandon the current iteration and restart from that point. I haven't seen any code in which people are doing anything even remotely similar.

I'm going to start looking at automating the process of editing my CSV file, so I can just code my test case to literally stop itself and restart itself with a new CSV. I'm pretty sure I could Ranorex the process of me editing the CSV if I just keep track of the row that it failed on. It seems ironic to automate Ranorex ranorexing itself. LOL.

I will have to make it store a special completed=yes flag somewhere after every iteration completes successfully, and then use that data to have Ranorex automatically hit the STOP button if the previous iteration doesn't create the completed=yes flag, open the CSV, delete every row except the current+next iterations, and then save it, and click the START button again.
Seems like a waste of time to be honest, but something like this is probably going to be the only way to restart a failed iteration without me sitting here manually updating the CSV, deleting every completed row and restarting the test case, which is highly undesirable when my CSV contains 200 iterations and takes 35 minutes.