Scripting your second test case with Katalon Studio IDE interface

This tutorial walks you through steps needed to manually write a very basic automation test script using Katalon Studio. You will understand and use import statements and pre-defined built-in keywords to compose test scripts. It’s recommended that you have some basic scripting background, preferably using Groovy language in order to use the scripting capability in Katalon Studio efficiently.

Refer to Record & Playback for details on how to create and execute test cases using Katalon Studio’s Record & Playback features.

Now, let’s manually write the first test script. Suppose that you have the following simple test scenario to automate:

  1. Launch a browser
  2. Open website “https://www.katalon.com”
  3. Verify that Katalon’s logo is presented within 10 seconds timeout
  4. Close the browser

Preparations:

  1. Create Katalon’s logo as a test object in Katalon Studio: use Object Spy to capture Katalon’s logo and insert it to the project. As the scope of this tutorial, we assume that you’ve already had Katalon’s logo object.

Figure 1: Captured Katalon’s logo is mapped into test object

2. Create your test case and select the ‘Script’ button to switch to Scripting View. This is the main view for editing automation test scripts in Katalon Studio.

Figure 2: Scripting View in Test Case

Understanding the context:

The import statement in a test script allows referencing to classes to be used. 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.

Figure 3: Default imported classes in Test Case

Katalon Studio is an automation tool that supports keyword-driven testing. All keywords are grouped into WebUI, Mobile and WebService packages accordingly. Press ‘Ctrl + Space‘ to view these packages and functions from the imported classes.

Figure 4:  WebUIMobile and WebService packages

In this scenario, you create a Web application test script, so select the WebUI package then press ‘.’ key to display all Web UI built-in keywords. You can filter the suggested keywords and functions by typing additional characters.

Figure 5: Available built-in keywords and functions based on imported packages

Composing a test script:

Test scenario steps:

  1. Launch a browser
  2. Open website “https://www.katalon.com
  3. Verify that Katalon’s logo is presented within 10 seconds timeout
  4. Close the browser

Let’s create a test script to execute this scenario manually.

1. Launch a browser:

In Katalon Studio, this step uses the “Open Browser” keyword in the WebUI package.

Launch browser Expand source

Figure 6: Add ‘Open Browser’ step

You can open a URL by including it in the parameter. If the parameter is ‘null’, then the browser shows the blank page.

2. Open website “https://www.katalon.com”:

Use the ‘Navigate To URL’ keyword with the parameter’s value of  “https://www.katalon.com” to navigate the current browser to Katalon’s website.

Open website “https://www.katalon.com” Expand source

 

Figure 7: Add ‘Navigate to URL’ step

3. Verify that Katalon’s logo is presented:

Use ‘Verify Element Present’ keyword to check if Katalon’s logo exists in the website loaded in the previous step.  Use ‘img_KatalonLogo’ for the test object parameter and 10 for timeout to wait for Katalon’s Logo to be loaded. The logo is checked after 10-second timeout.

Verify Katalon’s logo Expand source

Figure 8: Add ‘Verify Element Present’ step

4. Close browser:

Use the ‘Close Browser’ keyword to close the browser.

Close browser Expand source

Figure 9: Add ‘Close Browser’ step

Congratulations! You have finished your first automation script in Groovy language. Now you can execute the test script by clicking on Run.

For the visual tutorial on Scripting your second test case with Katalon Studio IDE interface, please check out the video created by Katalon Studio’s user at:

Share
Share on FacebookTweet about this on TwitterShare on LinkedIn
Share on FacebookTweet about this on TwitterShare on LinkedIn

Quick Start

    A quick guide to set up and start your first automation test with Katalon Studio, a complete test…

Creating the first test case with Recording utility

Record and Playback are the simple features that allow you to quickly create and run test cases. They are probably…

Setting up Web automation project

Starting a new automation project for a website can be complicated and requires a steep learning curve, especially to those…