Create Test Case

After you create your Katalon Project, it's time to generate your very first Test Case. Katalon Studio supports Keywords-Driven testing where Test Cases consist of keywords representing actions of users on the Applications Under Test (AUT).

The Manual view allows users with less experience in programming to generate automated tests. In addition to the Manual view, Katalon Studio allows users with Groovy/Java experience to programmatically write and modify automated tests in the Script view of Test Cases.

This tutorial will guide you through creating a new Test Case, then adding your test steps in Manual and Script view with usage examples.

Create a new Test Case

To create a new Test Case, first, open your desired Katalon Project. You can learn more about how to create projects at Project Settings.

On the right side of Katalon Studio, you can see the Test Explorer section containing access to all folders of your projects. In the Test Explorer, do as follows:

  1. Right-click on the Test Cases folder, select New > Test Case.

    new test case option

    Notes:

    For better management, you can also create a new folder by selecting Test Case > New > Folder, then create new Test Cases inside that folder.

  2. The New Test Case dialog appears. Enter your Test Case name, description, and tag. You can organize your project more efficiently by creating relevant Test Case names, tags, and providing detailed descriptions.

    new test case dialog

    After you are done, click OK. A new Test Case is created inside the Test Cases folder.

    Tags can be useful for large project management. You can learn how to manipulate tag properties at Test Case Management With Tags.

  3. Once a new test case is created, it is opened in Manual view. This view allows users to create automated tests with little programming skills required. You can switch to the Script tab to edit in Script view.

    manual view

Generate Test Steps in Manual View

The tutorial below will give you step-by-step instructions to create test steps in Manual view.

  1. In the Manual tab of the Test Case Editor, click Add. A new line representing a test step is generated.

  2. In the newly created test step, type a keyword, or click on the dropdown button to select a keyword. Add an Object, Input, Output, and Description for that test step, if any.

    keyword description

    Notes:

    To learn more about a keyword in Katalon Studio, hover over each keyword to see its description. You can also use the search bar on our Katalon Studio documentation page to find the detailed information and usage example of each keyword.

    You can also add a Statement or Call Test Case as a test step. To learn how Statement and Call Tese Case works, see: Statements and Call Test Case.

  3. Continue adding your test steps. You can also Move up, Move down, or Delete a test step.

    When you are done, in the main toolbar, click Run to execute the test case.

    run
Usage Example: Create a sample Test Case in Manual view

In our example, we use a sample test case with the steps as below:

  • Open the browser.
  • Navigate to a website.
  • Click on a specific control.
  • Validate if a control exists on the page.
  • Close the browser.
  1. Open the browser: Select the Open Browser keyword. This keyword opens a browser and navigates to the specified URL if provided.

    You can view the description of a keyword by hover your mouse over that keyword.

    open browser
  2. Navigate to a website: Add the Navigate To Url keyword. This keyword will navigate to a specified URL. Double click on the Input cell to provide additional data (parameters) for the keyword.

    navigate to url

    The Input dialog displays.

    input dialog

    For now, enter the URL of Katalon demo AUT (http://demoaut.katalon.com) into the Value column, then click OK.

Field Description
No The number of parameter for the selected keyword.
Param Name The name of the parameter.
Param Type The required data type for the parameter.
Value Type The type of your input value (e.g. strings, variables, data sources...)
Value

The input value for this parameter.

The input value can be varied based on Value Type. Refer to Value Types in Katalon for more details.

  1. Click on a specific control: Add the Click keyword. This keyword represents the click action on a given object. Double click on the Object cell and provide the object for the keyword. click

  2. Validate if a control exists on the page: All captured objects in Object Repository are displayed in the Test Object Input dialog. Select your object then click OK. To learn how to capture objects, see Spy Object.

    test object input

    Add the Verify Element Present keyword. This keyword validates if a certain object is displayed on the executing browser. Similar to the previous step, you need to specify the object to be used with this keyword.

    verify element
  3. Close the browser: Add the Close Browser keyword and save your test case.

    close browser

Recent Keywords

Recent keywords allow users to quickly add any of the last 10 recently used keywords in the Item list. To reuse recent keywords, in the Test Case editor, click on Recent keywords.

Recent Objects and Object Folders

Katalon Studio allows users to quickly select recently used objects or jump directly to the recently used Object Folder in the Object Repository.

In the Object column, double-click on any Test Object to open the Test Object Output dialog. Here, you can see the Recent Object button on the top right corner.

recent objects

The recent list will have two sections: Object Folder and Test Object.

  • Test Object: Displays the names of the last 5 selected objects.
  • Object Folder: Displays the names of 5 folders that contains any recently used objects.

Generate Test Steps in Script view

Once a new test case is created, you can switch to the Script view using the corresponding tab at the bottom of the test case editor. Test steps specified in the Manual view are translated into a Groovy script in Script view.

script view

By using the import statement in a test script, you can reference to the classes you wish to use. Expand the import section to see all default imported classes by Katalon Studio. The name after 'as' in each import statement is an alias for the class. You can change the alias for each class. These classes are necessary for composing a test script.

Use Built-in Keywords in Script view

Katalon Studio is an automation tool that supports keyword-driven testing. All keywords are grouped into webUI, mobile, web service, windows and cucumber packages accordingly. Press Ctrl + Space to view these packages and functions from the imported classes.

The following API docs may prove useful when working in Script view:

Class Description
Builtin Keywords List of common built-in keywords
WebUI Builtin Keywords List of Web UI built-in keywords
Web Service Builtin Keywords List of Web Service built-in keywords
Mobile Builtin Keywords List of Mobile built-in keywords

To use a built-in keyword, type the group keyword, for example, WebUI. for Web UI or WS. for Web Service.

The Content Assist function will be invoked after users enter the dot character. Content Assist provides users with a context-sensitive suggestion for code completion. Therefore, all the built-in keywords for WebUI testing will be displayed as below:

content assist

Refer to an Object in Script view

You can find any object ID from its Properties dialog. Go to Test Explorer > Object Repository. Right-click on an object and choose Properties.

find properties

To refer to an object in Object Repository, use findTestObject('{Object ID}'), in which Object ID is the ID of that object in Katalon Studio. You can also drag and drop the object into the Test Case editor to generate this syntax.

object properties
Usage Example: Generate Test Steps in Script view

In our example, we use a sample test case with the steps as below:

  • Open the browser.
  • Navigate to a website.
  • Click on a specific control.
  • Validate if a control exists on the page.
  • Close the browser.

In this scenario, you will create a Web application test script to make use of the Web UI built-in keywords. Follow these steps to automate the above test scenario in Script view:

  1. Open the browser: Type WebUI. and select the Open Browser keyword. This keyword opens a browser and navigates to the specified URL if it is provided. Selected keywords will have their description displayed along for reference.

    open browser
  2. Navigate to a website: Enter the Navigate To Url keyword. This keyword navigates to a specified URL. For now, enter the URL of Katalon Studio (katalon.com) as the value of the parameter.

    navigate keyword
  3. Click on a specific control: Enter the Click keyword. This keyword represents the click action on a given object. You need to specify an object for this action.

    click keywords
  4. Validate if a control exists on the page: Enter the Verify Element Present keyword. This keyword validates if a certain object is displayed on the executing browser. Similar to the previous step, you need to specify the object to be used with this keyword.

    verify element
  5. Close the browser: Add the Close Browser keyword and save your test case.

    close browser

Learn more with our Katalon Academy course: Create and Execute Test Cases.

Feedback