How can i make a test case repeat X number of times


I am trying to create a small performance test, is there a way to make a test case repeat X number of time without having X copies of the same script ?

thanks Vinh Nguyen

I have the same problem. If some one is kind enough to help me this, i would appreciate it.

Look at Test Suite Collections. You can add the one test case multiple times to the list and change the Execution mode to parallel. It’s crude but may work for you.

Hi there,

That’s simple, just add loop statement and call the current test case.


for (int i = 0 ; i < 5 ; i++)
//Execute this test case 5 times
WebUI.callTestCase(findTestCase('Main Test Cases/CurrentTestCase'), [:], FailureHandling.STOP_ON_FAILURE)


Thanks Vinh_Ngugen. The loops worked for me.

i copied the same code but now my test case is running infinite number of times

@Sara_Tavakolian ofcourse. You hust created a fork bomb, making the testcase call himself. Congrats!
The idea was to call the testcase, for a given number of times, from another, control, testcase

Here’s a more description method…
ANY test steps or test cases you want to put on loop, write the following script:

for (int i = 0 ; i < 10 ; i++)
Put all the test steps between the curly brackets

now, these steps will loop as many times as you provided. In this case, it will loop 10x as I provided i < 10.

To loop an entire test case:
do the same as above like Vinh has provided.

1 Like

Hi I copied this code but somehow my loop doesn’t execute again the first statement

Before the loop that you have shown, do you open the browser, move to the web page, position the elements in the viewport, etc., etc.? Do you actually have the elements that you have listed in your Object Repository?

Is there a specific error in the console log?

I have to run the same test case 100 times with different sets of test data. i.e. 1st time run- it will pickup the 1st row test data in excel and complete the script execution. 2nd time run- it will pickup the 2nd row test data in excel and complete the script execution. it need to run for 100 times. Please help

You could possibly use a “for” loop and that would allow you to use the loop counter as the reference for the row in the excel data.

for (int icnt=0; icnt < 100; icnt++) {

     "get row of excel using icnt"

I tried using for loop but I am getting only one report and test steps inside for loop is not getting displayed in report . Is there any way to get multiple reports and details

Let me assume you have a test case named Test Cases/Caller like this:

for (int i = 0 ; i < 5 ; i++) {
    //Execute this test case 5 times
    WebUI.callTestCase(findTestCase('Test Cases/Calee'), [:])

You will have only one report for the Caller. You will not get 5 reports about the Callee. It is not a problem. KS is designed as such.

What’s going on? I guess, the Caller works just like the following:

def Callee(Map args) {
    // the code of `Callee` is copy & pasted here

for (int i = 0 ; i < 5 ; i++) {

As you see, Callee loses its identification as a Test Case. The code of the Callee is transformed to be a part of Caller. So you can no longer identify the test case Callee in the report.

If you want to get 5 reports desperately, the only way you can take is to use “A Execution by Test Suite” of “Data-driven testing” as described at You want to give a data.csv like this:


If you give this (useles) CSV file to a Test Suite which is linked to a Test Case, then the Test Suite will invoke the Test Case 5 times, and will compile 5 reports.

ok . One more issue I am facing is if i gave a ‘for’ loop , then in the report I am not getting the steps after the ‘for’ loop

I couldnt see the steps of tc inside ‘for’ loop in report