Pricing
TABLE OF CONTENTS
Blog TOC Banner

Master StudioAssist: A quick guide to summarizing and explaining code in Katalon Studio

 

As a software testing professional, you know that efficiency is key. Whether you're reviewing your team's code or trying to understand complex test scripts, having a tool that simplifies these tasks can be a game-changer. Enter StudioAssist, an invaluable feature in Katalon Studio that can help you summarize and explain code easily. In this guide, we'll walk you through two essential use cases: generating a code summary and explaining your web test script. Let’s get started.

Code Summary: Quickly Understand Your Code

Imagine you're reviewing a colleague's code and want to get a quick overview before diving into the details. Or maybe you need to write a concise summary but are pressed for time. StudioAssist’s "Explain code" feature can handle this in just a few seconds.

Here’s how you can do it:

Step 1: Prompt Setup

Above your script, add the prompt, for example: Provide a summary of what this piece of code does, in 3 sentences.

 

Step 2: Highlight and Right-Click

Highlight the prompt, right-click, and select StudioAssist > Explain code.

 

Step 3: Review the Summary

StudioAssist will generate a summary like this: 

image3.png

For a more detailed explanation, you can simply select the code and choose Explain code. This time, StudioAssist will break down the code line by line:

/*
*  This class contains methods for logging into and logging out of an application.
*
*      - loginIntoApplication: 
*          - Parameters:
*              - String applicationURL: the URL of the application to log into.
*              - String username: the username to use for logging in.
*              - String password: the password to use for logging in.
*          - Steps:
*              1. Open the browser and navigate to the specified URL.
*              2. Maximize the browser window.
*              3. Wait for the specified element to be visible.
*              4. Enter the username and password.
*              5. Click on the login button.
*              6. Delay for 1 second.
*      
*      - loginIntoApplicationWithGlobalVariable:
*          - Steps:
*              1. Log into the application using the global variables for URL, username, and password.
*      
*      - logoutFromApplication:
*          - Steps:
*              1. Wait for the 'My Account' link to be present.
*              2. Click on the 'My Account' link.
*              3. Wait for the 'Logout' link to be present.
*              4. Click on the 'Logout' link.
*              5. Wait for the home page to be visible.
*/ 

Code example:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.annotation.Keyword
import com.kms.katalon.core.checkpoint.Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling
import com.kms.katalon.core.testcase.TestCase
import com.kms.katalon.core.testdata.TestData
import com.kms.katalon.core.testobject.TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable
/*
 * Open browser
 * Navigate to URL -> get to Global variable
 * Provide username and password
 * Click on Login
 * */
/*
 * Will read value from Global Variable
 * */
public class Login {
@Keyword
def static void loginIntoApplication(String applicationURL,String username,String password){
WebUI.openBrowser(applicationURL)
WebUI.waitForPageLoad(GlobalVariable.waitPresentTimeout)
WebUI.maximizeWindow()
WebUI.waitForElementVisible(findTestObject('Pages/MyAccount page/nav_HomeMyaccount'), GlobalVariable.waitPresentTimeout)
WebUI.sendKeys(findTestObject('Pages/MyAccount page/txtUsername'), username)
WebUI.sendKeys(findTestObject('Pages/MyAccount page/txtPassword'), password)
WebUI.click(findTestObject('Pages/MyAccount page/btnLogin'))
WebUI.delay(1)
}
@Keyword
def static void loginIntoApplicationWithGlobalVariable(){
loginIntoApplication(GlobalVariable.urlLogin, GlobalVariable.username, GlobalVariable.password)
}
@Keyword
def static void logoutFromApplication(){
WebUI.waitForElementPresent(findTestObject('Pages/MyAccount page/lnkMyAccount'), GlobalVariable.waitPresentTimeout)
WebUI.click(findTestObject('Pages/MyAccount page/lnkMyAccount'))
WebUI.waitForElementPresent(findTestObject('Pages/MyAccount page/lnkLogout'), GlobalVariable.waitPresentTimeout)
WebUI.click(findTestObject('Pages/MyAccount page/lnkLogout'))
WebUI.waitForElementVisible(findTestObject('Pages/MyAccount page/nav_HomeMyaccount'), GlobalVariable.waitPresentTimeout)
}
}

Here is a video of the entire process:

With StudioAssist, you can save precious time and quickly grasp the purpose of any piece of code.

Explain Your Web Test Script: Detailed Understanding Made Easy

When working on specific scenarios like testing a login page or a shopping cart, understanding each part of your test script is crucial. StudioAssist makes this process easy. Here’s how to use it:

Step-by-Step Guide:

Step 1: Open Your Script: 

Start by opening an existing test script in Katalon Studio.

image2.png

Step 2: Select the Code: 

Highlight the code area you want StudioAssist to explain.

image5.png

Step 3:Trigger StudioAssist

Right-click and choose StudioAssist > Explain Code, or use the hotkeys Ctrl + Shift + E for Windows or ^ + ⌥ + E for macOS for quick access.

image6.png

Step 4: View the Explanation

After a few seconds, StudioAssist will generate an explanation right below the selected script.

image1.png

This feature is especially useful when dealing with complex scripts or when onboarding new team members. It provides clear, detailed explanations that enhance understanding and improve collaboration.

 

You May Be Interested In:

  1. Mastering StudioAssist: Efficient Mobile, API, and Web Testing
  2. Mastering StudioAssist: Your Essential Guide to Data-Driven Testing and Reusing AI-Generated Test Cases

Conclusion

StudioAssist is a powerful tool that can transform the way you work with code in Katalon Studio. By summarizing and explaining code efficiently, it saves you time and helps you focus on what matters most—ensuring your tests are robust and reliable.

Ready to take your code review and understanding to the next level? Try StudioAssist today and see the difference it can make in your testing process. 

banner9.png