How to break loop once condition is met?

I am new to Katalon studio i have created one test case using Excel data. The main objective of the test case is user should be able to create more then one account and once all the accounts get created the test execution should stop. But in my case user is able to create more then one account but still the loop continue to create account using the same data and gives error. Following is my code snippet. Please anybody can help me how to resolve this issue?

TestData data = findTestData(‘TestData_SignUP’)

for (def index : (0…data.getRowNumbers() - 1)) {



WebUI._click_(_findTestObject_('Page\_Login/a\_Sign up'))   

WebUI._click_(_findTestObject_('Page\_Login/button\_Log out'))



please use excel sheet to fetch data and use for loop as follows:
for (row = 1; row <= findTestData(‘test_data_step2’).getRowNumbers(); row++)
your code goes here

Since ,you need to loop only twice you can use hard-coded value (2)

Thanks for the reply , but the loop is not working . I guess my code is in groovy language will this loop work for that too? because when i used the same pattern for looping its showing error.

Thanks for the reply . So the loop is working fine but it doesn’t stop once the condition is met. Like i have to create more then one accounts example gmail accounts , so with the help of loop at a time one after one i am able to create 3 to 4 accounts but when all the data from the excel sheet are done still the loop continues and start the same process with already used data. Is there any way to stop the loop once all the condition met ? The loop that i used :

for (def row = 0; row <= data.getRowNumbers(); row++)

The for loop can be stopped by the break command, for example:

if (i==5) break;

if you want to skip a row, the use the continue command, for example:

for (i in 1…10) {

if (i==5) continue;

println i