I have java classes in same package under Keywords but facing issues in importing those classes in other classes. sometime they work and provide me suggestion after dot (.) when I add import statement but other times they do not provide suggestions. Can some please help how can I import a simple custom java class that are in same package.
I have java classes in same package under Keywords
Could you elaborate this a bit more?
Possibly I would be able to answer to you question, but I need to know your codes more in order to write a readable description using you current code as example.
Where do you have the Java classes in question? Did you add a External jar file,which contains your Java classes in question, in the Drivers
folder? Or did you make Groovy classes without @Keyword annotation under the Keywords
folder? Could you share your codes to us.
sometime they work and provide me suggestion after dot (.) when I add import statement but other times they do not provide suggestions.
Could you take screen shots and share them here?
a simple custom java class that are in same package.
“Same” as what? same package as your Custom Keyword class, or something else? Please give us specific package name and class namess for example.
Hi Amit_Chauhan,
If your current editing class and the imported class is in the sample package, you don’t need to import them.
You can find the class by type the prefix of the imported class name, press Ctrl + Space to trigger the proposal suggest it.
If you want to find normal methods in the imported class, you should declare the imported class as a variable, type the variable name then press dot(.) to trigger proposal.
Eg:
YourImportedClassName object = new YourImportedClassName()
object.
If you want to find static methods in the imported class, you should type class name the press dot(.) to trigger the proposal.
Eg:
YourImportedClassName.
Thanks
In Java, you do not need to add import statements for classes that exist within the same package (they are actually automatically “imported” by the compiler).