Skip to main content

Create and edit test scripts in Script view

Last updated: August 2026

Use Script view when you need code-level control over a test case. You can write and maintain Groovy or Java code, use Katalon built-in and custom keywords, and refine scripts created in Manual view, by recording tools, or with Katalon AI Assistant.

Script view

Choose how to create or update a script​

MethodWhen to use it
Script viewWrite or customize test logic directly, including keywords, variables, methods, conditions, loops, and exception handling.
Generate CodeTurn a selected natural-language comment into code inside the active script editor.
Katalon AI Assistant Agent modeAsk Katalon AI Assistant to create or update project test cases using project context and MCP tools. Review the generated file changes before keeping them.
Manual view and recording toolsCreate keyword-driven steps visually or capture interactions first, then switch to Script view for code-level refinement. For Web UI tests, see Web Recorder Plus.
caution

AI-generated code can contain incorrect or nonexistent keywords. Review the script, referenced test objects, variables, and imports, then run the test case to validate the result.

Work with test scripts​

When you switch from Manual view, Katalon Studio translates the keyword-driven steps into a script. Expand the import section to review the default imported classes. The name after as in an import statement is an alias that lets the script reference that class with a shorter name.

Use built-in keywords​

Katalon Studio groups built-in keywords by testing type, including WebUI, Mobile, Web Service, Windows, and Cucumber. Type a keyword prefix followed by a period—for example, WebUI. or WS.—to open Content Assist and view relevant code-completion suggestions. You can also press Ctrl + Space or drag a keyword from the Keywords Browser into the editor.

Use built-in keywords in Script view

Use the API reference for complete class and method details:

ClassDescription
Builtin KeywordsCommon built-in keywords
WebUI Builtin KeywordsWeb UI built-in keywords
Web Service Builtin KeywordsWeb Service built-in keywords
Mobile Builtin KeywordsMobile built-in keywords
Windows Builtin KeywordsWindows built-in keywords

Refer to a test object​

  1. In Tests Explorer, expand Object Repository. Right-click a test object and select Properties to find its object ID.

    Find a test object ID
  2. Reference the object with findTestObject('<object-id>'). You can also drag the object from Object Repository into the script editor to generate the reference.

    Test object properties

Generate and explain code with Katalon AI Assistant​

Before using AI features, configure an AI provider. See Katalon AI Assistant overview for licensing, configuration, and current limitations.

To generate code in the script editor:

  1. Open a test case in Script mode.
  2. Write the intended actions as a single-line or block comment. Include relevant URLs, test objects, variables, and expected results.
  3. Select the comment, then right-click and select Katalon AI Assistant > Generate Code.
  4. Review the generated code. If required imports are missing, press Ctrl + Shift + O on Windows or Linux, or Command + Shift + O on macOS.
  5. Save and run the test case to validate the result.

To understand existing code, select a code snippet, then right-click and select Katalon AI Assistant > Explain Code. For the complete workflow and keyboard shortcuts, see Generate and Explain code in script editors.

For larger tasks, use Agent mode. It can use project context and Katalon Studio MCP tools to create or edit test cases, then show the affected files in Modified Files for review. This is more suitable than inline generation when a request spans multiple steps or project artifacts.

Intention groups in Script view​

note

Available in Katalon Studio 11.3.0 and later.

An intention group connects automation steps to a business-level purpose. When a test case contains an intention group, Script view represents it as a structured comment block around the related steps:

/**
* Start intention: ...
* @expected ...
*/
...
/** End intention */
ElementDescription
Start intention:The name that describes the intent of the grouped steps.
@expectedThe expected result after the grouped steps run.
@dataOptional test data used by the grouped steps.
End intentionMarks the end of the intention group.

For example:

/**
* Start intention: Open CURA home page
* @expected CURA home page is opened and ready for login.
*/
WebUI.openBrowser('')
WebUI.maximizeWindow()
WebUI.navigateToUrl('https://katalon-demo-cura.herokuapp.com/')
/** End intention */
Was this page helpful?