Java Scripting In Katalon

Hello there,

I have several Java tests that I made which I used to run via Eclipse using Chrome driver and Selenium server.
I’m trying to run my Java tests using Katalon now but couldn’t figure out how exactly I’m supposed to do that.

Is it even possible? If yes, how should I modify my scripts in order for them to run via Katalon?

I have attached one of my scripts for example.
Thank you in advance,

Login.txt

Hi roi,

I will guide you how to use that .java file as an executable script in Katalon Studio. You can optimize it based on your liking:

What you need to do is:
- Remove class and method declaration
- Remove ‘*’ for import statement.
Your overall script should be like this:

import java.util.concurrent.TimeUnit;
import org.openqa.selenium.By
import org.openqa.selenium.chrome.ChromeDriver;

//Initializing server
System.setProperty("webdriver.chrome.driver", "C:/selenium/chromedriver.exe");
ChromeDriver wd = new ChromeDriver();
wd.manage().window().maximize();
wd.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
//login
System.out.println("*** login ***");
wd.get("<URL>");
wd.findElement(By.xpath("//form[@id='form']/div[1]/paper-input/paper-input-container/div[2]/div/input")).click();
wd.findElement(By.xpath("//form[@id='form']/div[1]/paper-input/paper-input-container/div[2]/div/input")).clear();
wd.findElement(By.xpath("//form[@id='form']/div[1]/paper-input/paper-input-container/div[2]/div/input")).sendKeys("<USERNAME>");
wd.findElement(By.xpath("//form[@id='form']/div[2]/paper-input/paper-input-container/div[2]/div/input")).click();
wd.findElement(By.xpath("//form[@id='form']/div[2]/paper-input/paper-input-container/div[2]/div/input")).clear();
wd.findElement(By.xpath("//form[@id='form']/div[2]/paper-input/paper-input-container/div[2]/div/input")).sendKeys("<PASSWORD>");
wd.findElement(By.xpath("//form[@id='form']//paper-button[.='login']")).click();
try { Thread.sleep(3000l); } catch (Exception e) { throw new RuntimeException(e); }
if(wd.findElement(By.tagName("html")).getText().contains("please login")){
	System.out.println("Login failed");
throw ioe;
}//End of login
System.out.println("Login was executed successfully!");
System.out.println("Testcase finished successfully!");
wd.quit();

My saviour!!..Thank you very much :wink: