Since Groovy 3.0.0.0 was introduced in the new version of Katalon 9.0.0, I understood that the Do-While loop could be used. I tried the following code but got the error:
Groovy:unexpected token: do Utils.groovy
do {
element = driver.findElementByIosNsPredicate("label == '${text}'")
if (!element.isDisplayed()) {
Mobile.swipe(startX, startY, startX, endY)
}
} while (!element.isDisplayed())```
3 Likes
Do … while does not work for me as well.
1 Like
Hi @jhilario , @kazurayam
If you want to use Groovy Syntax 3.0, please follow the below steps:
Go to Katalon execution folder
open katalon.ini
add -Dgroovy.antlr4=true
in the end of the file and save
Restart Katalon Studio
Hope it can help
5 Likes
duc.tnguyen:
-Dgroovy.antlr4=true
I tried it, but doesn’t work in the Katalon Studio Arm64 binary.
I read an article
Apache Groovy is coming up with a new parser, that supports the Java 8 syntax elements, as well as some new notation and operators of its own (like !in, !instanceof or ?[] for safe navigation with collections, or with ?= for Elvis assignment). I...
According to this article, there is one more necessary step. It says
Build Apache Groovy from the master branch with the Antlr4 parser:
./gradlew -PuseAntlr4=true installGroovy
I guess the Groovy parser bundled in the Katalon Studio Arm64-9.0 binary was NOT built with the Antlr4 parser.
By the way, I personally don’t need the do ... while
syntax. Just I was interested in this topic.
1 Like
Can you explain more this step
./gradlew -PuseAntlr4=true installGroovy
1 Like
The article “Trying out Apache Groovy's new Antlr4 parser with Java 8 support ” explains that the command is to build Groovy with the new Parser which recognizes the “do … while” syntax. The new Parser is generated using ANTLR4 , a Parser Generator. The code name of the new Parser is Parrot .
I guess that Katalon Studio Arm64.app
as v9.0.0 does not contain Groovy built with Parrot. It contains Groovy built with previous parser.
I found that Katalon Studio Arm64.app as v9.0.0 contains Groovy v3.0.17.
So I may be wrong in saying that Katalon Studio Arm64.app as v9.0.0 does NOT contain Groovy appropriately built to support do ... while ...
syntax.
Then do not know why the instruction by @duc.tnguyen does not work.
1 Like
@duc.tnguyen 's instruction worked for me.
I made a silly typing mistake in the katalon.ini
.
Wrong:
ーDgroovy.antlr4=true
Right:
-Dgroovy.antlr4=true
3 Likes
This works for me!! Thanks!!