Hi @Katalonbetaguy,
I don’t know exactly what you want to extract into custom keywords. However, for example, if you want to convert your method readFromExcel to a keyword, you can define a groovy keyword file as the following:
package your_package
// define your imported packages here
public class ExcelKeywords {
@Keyword
def readFromExcel(String file) throws IOException {
//put your code here
}
}
hi,
it's not necessary to use keywords (recommendation), so you can use pure java classes in Katalon testcase script
like this way
for (CrunchifyEnumExample.Company cName : CrunchifyEnumExample.Company.values()){
//System.out.println("Company Value: " + cName.value + " - Company Name: " + cName);
switch(cName.value){
case 30:
println "Company Name: "+cName
break
case 10:
println "Company Name: "+cName
break
case 15:
println "Company Name: "+cName
break
case 20:
println "Company Name: "+cName
break
case 25:
println "Company Name: "+cName
break
default:
println "no values!!!"
break
}
}
public class CrunchifyEnumExample {
public enum Company {
EBAY(30), PAYPAL(10), GOOGLE(15), YAHOO(20), ATT(25);
private int value;
private Company(int value) {
this.value = value;
}
}
}
You can put your Java class into the /Keywords/ directory and rename them from *.java to *.groovy. It would work.
But all files contained in the <project>/Test Cases/ directory will be regarded as code written in Katalon-original Domain Specific Language (similar to Groovy script, but not Groovy class).
Do you want to see a Test Case script as an example of calling Apache POI API? Then have a look at this:
You can easily see that this code does not have class XXX { ... }. As you know, Java requires class everywhere. In Test Case script, you can not write class XXX { ... }.