Skip to main content

Create a Test Case in Katalium Framework

Test cases are essentially TestNG's test classes. Katalium Framework provides an abstract class com.katalon.kata.testng.TestTemplate with some convenient utilities:

  • WebDriver is initialized before each test method and can be accessed with this.driver or driver. If the test method ends with a driver.quit() statement, a new WebDriver will be created for the next test method.

  • Page instances are also preinitialized using Selenium's PageFactory. Refer to this article to learn more about the Page Object Model.

Here is a very simple Selenium test (source code):

package com.katalon.kata.sample.testcase.simple;

import com.katalon.kata.sample.Constants;
import com.katalon.kata.sample.page.CuraAppoinmentPage;
import com.katalon.kata.sample.page.CuraHomePage;
import com.katalon.kata.sample.page.CuraLoginPage;
import com.katalon.kata.testng.TestTemplate;
import org.testng.Assert;
import org.testng.annotations.Test;

public class LoginTest extends TestTemplate {

private CuraHomePage curaHomePage = new CuraHomePage(Constants.baseUrl);

private CuraLoginPage curaLoginPage;

private CuraAppoinmentPage curaAppoinmentPage;

@Test
public void shouldLogin() {
curaHomePage.open();
curaHomePage.makeAppointment();
curaLoginPage.login(Constants.username, Constants.password);
boolean exist = curaAppoinmentPage.isOnPage();
Assert.assertTrue(exist);
driver.quit();
}
}