@Keyword
public String generateEmail () {
Date today = new Date();
String todaysDate = today.format('YYYYMMdd');
String nowTime = today.format('HHmmss');
String email = ((('ua-' + todaysDate) + 'T') + nowTime) + '@mailinator.com';
return email;
}
I use the above code in two different projects. In the first project, everything works as expected. In the second project(which was made more recently), Katalon does not recognize either .format() method, as shown by the runtime error. The entire class was copied from the working project. I also tried using the following code and it produced the same issue on the .format() methods, as suggested in Katalon Studio 7.9 rc - Bug in Date().format(<String>).
@Keyword
public String generateEmail () {
Date today = new Date();
SimpleDateFormat date = new SimpleDateFormat('YYYYMMdd');
SimpleDateFormat time = new Date('HHmmss');
String email = ((('ua-' + date.format(today)) + 'T') + time.format(today)) + '@mailinator.com';
return email;
}
org.codehaus.groovy.runtime.InvokerInvocationException: groovy.lang.MissingMethodException: No signature of method: com.MyKeywords.Date.format() is applicable for argument types: (java.lang.String) values: [YYYYMMdd]
Possible solutions: getAt(java.lang.String), print(java.io.PrintWriter), print(java.lang.Object)
at com.MyKeywords.Email.invokeMethod(Email.groovy)
at com.kms.katalon.core.main.CustomKeywordDelegatingMetaClass.invokeStaticMethod(CustomKeywordDelegatingMetaClass.java:50)
at Given_NoAccount_BookAPartyAsIntended.run(Given_NoAccount_BookAPartyAsIntended:98)
at com.kms.katalon.core.main.ScriptEngine.run(ScriptEngine.java:194)
at com.kms.katalon.core.main.ScriptEngine.runScriptAsRawText(ScriptEngine.java:119)
at com.kms.katalon.core.main.TestCaseExecutor.runScript(TestCaseExecutor.java:369)
at com.kms.katalon.core.main.TestCaseExecutor.doExecute(TestCaseExecutor.java:360)
at com.kms.katalon.core.main.TestCaseExecutor.processExecutionPhase(TestCaseExecutor.java:339)
at com.kms.katalon.core.main.TestCaseExecutor.accessMainPhase(TestCaseExecutor.java:331)
at com.kms.katalon.core.main.TestCaseExecutor.execute(TestCaseExecutor.java:248)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:142)
at com.kms.katalon.core.main.TestCaseMain.runTestCase(TestCaseMain.java:133)
at com.kms.katalon.core.main.TestCaseMain$runTestCase$0.call(Unknown Source)
at TempTestCase1626466343503.run(TempTestCase1626466343503.groovy:25)
Caused by: groovy.lang.MissingMethodException: No signature of method: com.MyKeywords.Date.format() is applicable for argument types: (java.lang.String) values: [YYYYMMdd]
Possible solutions: getAt(java.lang.String), print(java.io.PrintWriter), print(java.lang.Object)
at com.MyKeywords.Email.generateEmail(Email.groovy:10)
… 14 more