Table of Contents
Enroll in Selenium Training

In addition to the Manual view, Katalon Studio allows expert users to programmatically write automation tests in the Script view of test cases. Moreover, users with Groovy/Java background can easily modify the test script as needed. Subsequently, this tutorial, create a test case using script mode, will walk you through the steps needed to write a fundamental automation test script using Katalon Studio manually.

After going through this article, you will be able to understand and use import statements and pre-defined built-in keywords ( to compose test scripts. Moreover, we recommend that you should have some basic scripting background, preferably using ***Groovy ***( language. Additionally, this will help you to use the scripting capability in Katalon Studio efficiently and will help you to create test case using script mode.

Following is a sample test case with the steps as written below:

  • Firstly, open the browser.
  • Secondly, navigate to a website.
  • Thirdly, click on certain control.
  • After that, validate if the control exists on the page.
  • Finally, close the browser.

Follow these steps to automate the above test scenario in the Script view:

  1. First, select File > New > Test Case from the main menu. Consequently, the New Test Case dialog will be displayed. Provide the name for the new test case. After that, click OK.

new test case Katalon Studio

  1. Secondly, once a new test case creation completes, you can switch to the Script view using the corresponding tab at the footer of the test case editor. Additionally, observe how test steps of the Manual view translate into Groovy script of Script view.

Script mode Katalon Studio

The import statement in a test script allows the usage of referencing classes. After that, expand the ‘import’ section to see all default imported classes by Katalon Studio. The name that appears after ‘as’ in each import statement is an alias for the class. You can change the alias for each class. Moreover, these classes are necessary for composing a test script.

Katalon Studio is an automation tool that supports/ enables keyword-driven testing. Since version 5.4, Katalon Studio provides users an option to generate sample custom keywords for WebUI, Mobile, WebService, Windows, Cucumber, Utilities, and Common Assertions accordingly. For example, in WebUI testing, you can get the text of an alert popup using Get Alert Text keyword. Similarly, you can modify the property to test objects using Modify Object Property keyword, verify if alert presents, or not using Verify Alert Present keyword and so on.

  1. Thirdly, in this scenario, you will create a Web application test script so that you can make use of the Web UI built-in keywords. Moreover, to use a built-in WebUI keyword, enter the following syntax into the editor.


  1. Fourthly, the Content Assist function will invoke after users enter the dotContent Assist. It provides users with a context-sensitive suggestion for code completion. Therefore, all the built-in keywords for WebUI testing will display as below:

Content Assist Dialog Katalon Studio

  1. Fifthly, select the Open Browser. This keyword will open up a browser and navigate to the specified URL if given. Moreover, selected keywords will have their description displayed along for reference.

Open Browser Katalon Studio

  1. Sixthly, enter the Navigate To Url( This keyword will navigate to a specified URL. For now, enter the URL of Katalon Studio ( which will act as an input parameter.

Navigate URL keyword Katalon Studio

  1. Seventhly, enter the Click ( This keyword represents/ depicts the click action on a given object. Moreover, you need to specify an object for this action.

Click keyword Katalon Studio

  1. After that, use the following syntax to refer to an object in Object Repository. Alternatively, you can also drag and drop the object to test case editor to generate the syntax :

findTestObject('{Object ID}')

Where, Object ID is the ID of that particular object in Katalon Studio.

  1. Consequently, you can find object ID from its Properties dialog. For example:

Object ID Properties

  1. In addition to the above, enter the Verify Element Present ( This keyword validates the display of a specific object on the executing browser. Similar to the previous step, you need to specify the object to use with this keyword.

Verify element present

  1. After that, add the Close Browser ( keyword and save your test case.

Close Browser keyword Create test case using script mode

  1. Additionally, the following API docs may prove useful when working in the Script view:
Class DescriptionDescription
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
  1. Congratulations! Finally, you have finished your first automation script in Groovy language. After that, click on Run in the main toolbar to execute the test case.

Run Katalon Studio Create test case using script mode

Katalon Studio should be able to execute/ run all the steps of the sample test case. Moreover, you can see the Test Execution result in Log Viewer. For example:

Test execution Dialog Create test case using script mode

Configuring Katalon Studio for the Web automation test project
Configuring Katalon Studio for the Web automation test project
Previous Article
Handle iFrame issue in Katalon Studio
Handle iFrame issue in Katalon Studio
Next Article

Similar Articles