3

As we know Katalon has now become a paid tool so my Katalon scripts need to be converted into Selenium and Java script. Katalon scripts are in Groovy, and it's written using Katalon Built-in libraries, objects are saved in .rs(.xml) fie on Object repository and user-defined Keywords are also in Groovy. So please suggest the best way(time-saving) to convert scripts into selenium.

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Ajeet Yadawa
  • 135
  • 3
  • 16

2 Answers2

3

I don't think there is a simple way to convert all of your scripts to Selenium.

Katalon keywords are a wrapper around various Selenium commands (or code snippets) so a one-to-one Katalon-Selenium relationship is not always present. Therefore, one simple way of translating one to another does not exist.

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
  • Yes, you are right one to one Katalon to Selenium not possible. But in some extent you can create wrapper class and methods with same name as Katalon have then you can accelerate your transformation. So first figure out what katalon methods you used, make utlity (XML Parser to convert Katalon Object into Selenium), use Cucumber for BDD or testng for Test Suite Managment and write your own mail sending methods. In other words you have to analyze Katalon Studio and write your own methods with same name which helps to transform script quickly. – Ajeet Yadawa Apr 25 '20 at 05:13
3

Finally, able to convert Katalon script into Selenium. Refer below to make your own Katalon Studio:

Step 1. Create an interface and store Global variable

public interface RunnerConstants {
readByExcel rd=  new readByExcel("Login.xls","LoginData");
public static final String url= rd.getexcelCellData(2, 0);
public static final  String userName= rd.getexcelCellData(2, 1);
public static final  String password = rd.getexcelCellData(2, 2);
public static final  String subscriberid = rd.getexcelCellData(2, 3);
public static final  String browserName = "Chrome-Headless";

}

Step 2: Make an element class and store WebElement( use page Factory concept)

public class takeElement {

static WebDriver driver= webD.getInstance();

@FindBy
public static WebElement inputLogin = 
 driver.findElement(By.xpath("//input[@id='loginID']"));
@FindBy
public static WebElement inputSubscriberId  = 
driver.findElement(By.xpath("//input[@id='subscriberID']"));


@FindBy
public static WebElement submitbtn= 
driver.findElement(By.xpath("//input[@id='submitLogin']"));
}

Step 3: Create a web driver singleton class How to get webdriver instance to use same instance across all class files

Step 4: Implement Katalon methods as static in WebUI class.

 public  class  WebUI {

 static WebDriver driver = webD.getInstance();
 public static void setDriver(WebDriver driver) {
    WebUI.driver = driver;
 }  
 public static void openBrowser(String url) {
    driver.get(url);
 }
public static void navigateToUrl(String url) {
    driver.navigate().to(url);
}
}

Step 5: Write your script using TestNG annotations

 public class test {


 @Test
 public void testA() {
 WebUI.openBrowser(RunnerConstants.url);
  WebUI.setText(takeElement.inputLogin, RunnerConstants.userName);
 WebUI.setText(takeElement.inputPassword, RunnerConstants.password);
 WebUI.setText(takeElement.inputSubscriberId, RunnerConstants.subscriberid);
 WebUI.click(takeElement.submitbtn);
 WebUI.closeBrowser();
  }
}

Using the above ways, you can reuse your Katalon script. I hope it helps!!

Mate Mrše
  • 7,997
  • 10
  • 40
  • 77
Ajeet Yadawa
  • 135
  • 3
  • 16
  • I took this as base idea and developed many utilities and methods with same name which helps me to quickly convert scripts. – Ajeet Yadawa Apr 25 '20 at 05:17