Katalon external library - katalon-studio

I'm trying to use my own code for Katalon as a library.
My own code has imports like this
from com.test.page import Page
from selenium.webdriver.common.keys import Keys
import robot.utils.asserts as asserts
This file is totally executable on its own when I'm using IDE, but when I tried to import it to Katalon, I got exception message like this
ImportError: No module named test

In order to use external references, you should go to the IDE and select
Project -> Settings -> External Libraries
On the window add your jar file.
Remember that you also need to check if the .classpath file is updated accordingly if you use git (it's on the .gitignore list, so needs to be updated manually)

Do you put your .jar in Drivers folder inside your project?
Write import com.test.page.Page instead of yours

The best place to keep all jar files is to create a folder in Katalon folder structure and store all jar files in it. When you commit Katalon project into a source repositories like Github and SVN, don't forget to commit jar files as well so that the references given in the code will no throw an error.

Try this:
put additional jars in lib directory like "C:\Users[ME].katalon\8.2.0\Katalon_Studio_Engine_Windows_64-8.2.0\configuration\resources\lib\jsch-0.1.54.jar".
restart katalon then in your script, use import com.jcraft.jsch.*;

Related

I am not able see the jar package structure,but there are no errors

I have following import in my class
import org.apache.commons.lang.exception.ExceptionUtils;
ExceptionUtils is indeed referenced in my class.
JOptionPane.showMessageDialog(this, "An Server Error occured during saving.\n\n" + ExceptionUtils.getStackTrace(e), "Error",**
But in the classpath i have package org.apache.commons.lang3
I am really not sure how this runs and why there are no errors?
I am using Eclipse Indigo
Please advice.
It sounds like your Apache Commons Lang .jar file satisfies your org.apache.commons.lang.exception.ExceptionUtils import.
Look here:
http://www.java2s.com/Code/Jar/a/Downloadapachecommonslangjar.htm
STRONG SUGGESTION:
Take a look inside of your .jar file. One easy way to do this is with a tool like 7-Zip, or jd-gui. Another way is to temporarily rename the file from .jar to .zip, and look at its contents in Windows Explorer.
This will show you the packages (directories and subdirectories) and classes inside of the .jar.
Interesting stuff - try it sometime!

Getting imported files from sample java program to new program

I'm trying to make a small java program revolving around Google Calendars. I've never worked with java before but I was able to get Google's sample code working. In Eclipse, I simply used Import -> Maven, and then made some small changes to the code so that it worked on my Calendar.
Ok, great, now I want to write my own code. I started a new project and imported the Google Calendar API. At the very beginning, there are several import actions:
import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.extensions.java6.auth.oauth2.AuthorizationCodeInstalledApp;
import com.google.api.client.extensions.jetty.auth.oauth2.LocalServerReceiver;
import com.google.api.client.googleapis.auth.oauth2.GoogleAuthorizationCodeFlow;
.
.
.
It turns out that I'm missing the second and third files. How do I find these files and how to do import them to the new project?
Please note: I ultimately don't want to rely on importing the Google Calendar API or anything similar, as I will be using another non-java program to run and control this one.
Here's what I tried:
I go back to the sample code, expand Maven Dependencies and find:
google-oauth-client-jetty-1.19.0.jar
google-oauth-client-java6-1.19.0.jar
I see that these files are in:
C:\******\.m2\repository\com\google\oauth-client\google-oauth-client-jetty\1.19.0
C:\******\.m2\repository\com\google\oauth-client\google-oauth-client-java6\1.19.0
I tried to add these with Import -> Java EE -> App Client JAR file
Didn't work, do I need to change the file name or import name? Maybe these aren't the correct files anyway.
I also tried to add these by creating a lib folder in my project folder and add the JAR files directly there.
I guess from your question your project is just an Eclipse project rather than a Maven project. Obviously Maven automatically add the required jars of the dependencies stated in pom.xml for example google-oauth-client-java6-1.19.0.jar is a dependency of google-oauth-client-jetty-1.19.0.jar.
To add external jar to your project in Eclipse you need to select the project then from the Project menu select Properties. On the properties popup click on the Java Build Path, you have two options depending where the jars are stored, if you are referring to the maven .m2 directory then choose 'Add External Jars' otherwise if you added them to a lib folder in the project choose Add Jars

jar to eclipse project

I got a .jar file which I need to import into Eclipse. However, I don't want to have the jar as a referenced library. I need the .jar to be included like a "normal" project, with packages(!) and .java files.
I tried to do the following: New Java project -> Import -> General -> Archive File. In this case, when I place this jar also as a referenced library, it is imported but with .class files.
New Java Project -> Import -> General -> File System. Imports the .java files, but the packages are lost and are normal folders. Also, the files are somehow strange, because the "j" in the icon looks differently, and errors are not noticed (no underlining)
Importing "Existing Projects into Workspace" doesn't work at all, it says that there is no project. I also tried to import the jar as a zip after extracting it, this gives me the -java files, but it destroys the packages.
Does anyone know how to import this correctly?
What are you trying to do here ? .jar files would contain .class files not .java files. Either you need to have the corresponding source in the jar or you gotta get a decompiler associated with Eclipse.

intellij Import eclipse

I just recently start to try to move to intellij. After trying it several time i have decided to make the big move. I have downloaded an evaluation of ultimate.
hence i have decided to import my project from eclipse. However i am having some difficulties.
1- When I import a project as a module (inside a a project in Intellij) for which i clearly specify where i would like the project to be imported (i.e. "Keep project and module files in") (i.e. in a folder of the original name inside the current intellij encompassing project folder)
>>>Intellij do not import the files but references the eclipse project from whithin a new folder that it create. I do not want to mix my source. I want to duplicate the source and have it in intellij. But intellij, is actually pointing to my eclipse project.
This is an issue for me. Is there a way to avoid that ?
The question how does the import actualy behave. Does it duplicate the all files and create a new dir with all the duplicate files and the conig, or does it simply create a new dir, with conf files that point to the old dir.
What should i do, if i want to go from a project A in clipse to a project A' in Intellij with A' as a clone of A where both are fully independent project ?
Can any one help or assist on this. Many thanks.
Import will not duplicate any files, it will create IntelliJ metadata (.idea, *.iml, *.ipr) files inside your project, so you can work on the same codebase with both IDE simultaneously. Also, you can establish a two-way sync, with Eclipse project configuration changes synced to IntelliJ module and vice versa.
Unless you want to create an independent copy of your original project(as you mentioned in the question), then just copy the contents into a new directory and import the cloned code into IntelliJ. The changes you make in one project will not be reflected in another project.
If you are using git, then you can simply clone the existing git repository.
$ git clone my-eclipse-project my-idea-project

Java import directories

I want to ask smaller question about Java VM and thing about it.
If I understand import process correctly, then when I request contents of packages by import keyword in Java, packages are being imported from it's specified import directory. Then when I'm running Java application from a directory in computer and some of the imported packages could not be found in JVM import directory, JVM is looking for them in current directory. But in that case something must be wrong, because when I run my project from Eclipse and I request some package from the project, it's found. I think that Eclipse is changing directory where packages are being searched. Am I right? Is this all way of importing in Java?
The import statement is just syntactic sugar so you don't have to specify the fully qualified name everywhere in your classes. It doesn't actually import anything in terms of code.
Classes are looked up in the classpath.
In eclipse you can configure the build path (for each project) option project - - > build path.
There you can either add a directory, jar file, external jar files, etc.
Also you can check what's already defined.