'There are errors in the script' caused by imports

Hi all,

I’m trying to import some things from Apache POI and Java.io.File in a testscript. Specifically, I have the following imports in my script:
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testobject.ConditionType as ConditionType
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import org.apache.poi.ss.usermodel.*
import org.apache.poi.xssf.usermodel.*
import java.io.File.*

When I try to switch to manual view, I get the error ‘There are errors in the script. Please fix them before switching to manual mode.’
This error does not occur when I remove the last 3 imports.
The error occurs when I remove all of the scripts itself (i.e. I have a testscript that is just these imports, and the error still occurs)
Pressing CTRL+Shift+O (with the rest of the script included) does not remove or change them (it does change the order of these imports).
These errors are not highlighted in script view, and therefore Katalon won’t tell me what the problem is.

Does someone know what the problem is?

Look in here…

There are no problems listed there either.

Try import class with their full package name.
See Star import statement.* in a test case is regarded as error

1 Like

Try static imports (it won’t work with everything, but sometimes…)

import static org.apache.poi.ss.usermodel.*
1 Like

This fixed it. Thanks!

Interestingly, this fixes it too.

Out of curiousity: do you know what causes this issue?

There are a couple of things going on here…

  1. Katalon is not reporting the nature of the problem giving you no idea as to how to proceed.

  2. If the imported class is declared as a list of static members, you must call them in a static context (that’s what import static does)

With #1 being the root cause, you can only try #2 and see what happens.

Regarding @HeleneB’s link. I have no idea what’s going on there so I can’t comment.

1 Like