Organize imports shortcut misses common imports

Describe the problem you have.

Organize imports/auto import function does not find common aliases and also doesn’t include findTestObject, findTestCase, etc.

Please let us know, how would your work be affected while this request has not been resolved?

I can continue my job, resolving this ticket can boost my performance

Describe the feature you’d like or how the current features need to be updated

I’d like the auto import shortcut (ctrl+shift+o) to check for common package aliases, and also to work properly with findTestObject, etc (I realize that latter request is more of a bug report, but the former is more of a feature request). Currently, when you create a new keyword or testcase file, it comes with a bunch of imports provided by default. This includes several aliased packages, such as WebUI (this is the only one I tested, but I assume it’s the same thing with the other ones as well). However, if you try to add this import to a file by using the ctrl+shift+o command, it doesn’t add, presumably because ‘WebUI’ is an alias and not the actual package name.

Since Katalon Studio itself provides these aliases, and they are referred to frequently on these forums, I think the auto import should seek them out and add those imports when used.

The other issue is with the packages with methods like findTestObject or findTestCase (I assume the other find-- methods have the same issue, but I haven’t tested them). Despite not being aliased, these just don’t get imported by the keyboard shortcut.

Eclipse support content assist for “import static” by Ctrl+Shift+o as http://www.eclipseonetips.com/2010/02/01/generate-static-imports-in-eclipse-on-autocomplete/ tells. I tried it but failed. Katalon Studio seems not supporting it. I do not know why.

@duyluong
@Jass

Can you improve this?


as” is a special keyword of Groovy Language, which allows you to give “an alternative name of your choice”. I think there is no software that can intelligently guess your choice “as”. I think KS would be never be able to guess “as WebUI” by Ctrl+Shift+o. “import FQCN as Name” is not supported in Eclipse Groovy editor. I am negative that Ctrl+Shift+o will ever have this in future.

The easiest workaround could be creating a blank Test Case “New Test Case” in Katalon Studio GUI, which will have a list of default import statements like:

import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI

You can copy any part of the import statements from it when needed.

1 Like