How to use do while loop in katalon

Hello Team,

How to perform do while loop in Katalon?

When we enter do{
}while(true);

it is giving an error, unexpected token: do

@devalex88 @kazurayam please help .

There is no do {} while () syntax in Groovy language.

See

Thanks @kazurayam

This is incorrect as of Groovy 2.6 and is mentioned in the stack overflow answer linked above. It requires using the Parrot parser to get access to new syntactical options.

Here is the official documentation: https://groovy-lang.org/semantics.html#_do_while_loop

What do you mean “this is incorrect”?

This document describes the latest Groovy 3 syntax.

Inside Katalon Studio, we can only use Groovy 2.4.X. We can not use Groovy 3 syntax in Katalon Studio.

do while syntax is indeed now available (since Groovy 2.6, and now 3.0). However, it is unfortunately up to Katalon developers to update to a compatible version, which it looks like they tried at one point, gave up on it, and slated it for the 8.0 release (which is now out). So, who knows what they’re doing now…

1 Like

In Katalon 8.6.0 do {} while () does not work.
Error: Unexpected token: do

This works

while () {} 

Hopefully, Katalon will add this structure soon

Katalon Studio uses Groovy version 2.4.x.

In Groovy version 2.4.x, the do {} while … loop is not supported. You can check the language document at

https://docs.groovy-lang.org/docs/groovy-2.4.21/html/documentation/#_looping_structures

The do {} while … loop was added at the version 3.0 of Groovy language

https://docs.groovy-lang.org/docs/groovy-3.0.0/html/documentation/#_do_while_loop

However, as far as I am aware, Katalon team has no intention to move to Groovy v3.0 in Katalon Studio.

I don’t think they will do it. Katalon team has ever tried it but encountered difficulties; they abandoned their intent. See the following post:

One workaround you could use? Insert the test after your other steps, to ensure it runs at least once eg:

int i = 0
while (true) {
//insert any steps here
i++
if (i>= 3) {
break
}
}

Hi @kazurayam and all,

The do {} while … loop was added at the version 3.0 of Groovy language
https://docs.groovy-lang.org/docs/groovy-3.0.0/html/documentation/#_do_while_loop
However, as far as I am aware, Katalon team has no intention to move to Groovy v3.0 in Katalon Studio.

Thanks for mentioning this again.
Katalon Studio team are working on a major change that includes Eclipse framework (4.16 to latest), Groovy (2.0.20 to 3.0.x) and Java upgrade (Java 8 to Java 17).
We hope this change will improve Katalon Studio performance especially with Groovy editor and allow user to script with latest Java and Groovy technologies.

We cannot confirm the ETA for now but we hope we can publish a pre-release version in next couple of months.

@duyluong will be the new version backward compatible with openjdk-8?
i am not concerned about KSE.
but will be fun to see, all existing CI integrations using KRE starts to fail.
because, of-course, java 17 is needed now.

good luck with this change!

Hi @anon46315158,

will be the new version backward compatible with openjdk-8?
i am not concerned about KSE.
but will be fun to see, all existing CI integrations using KRE starts to fail.
because, of-course, java 17 is needed now.

I think new KS/KRE v9.x will require JRE 17 and is incompatible with JRE 8 because Eclipse platform requires JRE 11 as the minimum version on their versions: https://wiki.eclipse.org/Eclipse/Installation#Eclipse_4.17_.282020-09.29

We acknowledge some users on Linux should update their CI script so we will let this version as alpha long enough and also warn users that this is a major version change so they need to do some tasks to migrate.
For Windows and macOS, users probably don’t need to change their CI script because we already embed JRE/JDK in KRE.

2 Likes

Well … I suppose, It has to be done, one day.
The later, the more complicated will be the transition.

Another interresting case will be, for users using plain java to write test cases.
I have no idea on what levels java 17 changed the API’s compared whith java 8, as I am not a prolific users, but most probably some stuff may break also here an there.

Groovy scripts should be more backward compatible … but in practice it is not like in theory.
Will be fun to play with the new version, I will keep an eye on the announcements!