Skip to main content

Generate test steps in Katalon Studio 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:

Builtin KeywordsList of common built-in keywords
WebUI Builtin KeywordsList of Web UI built-in keywords
Web Service Builtin KeywordsList of Web Service built-in keywords
Mobile Builtin KeywordsList of Mobile built-in keywords
Windows Builtin KeywordsList of Windows 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:
use built-in keywords in script view

Refer to an object in script view

  1. You can find any object ID from its Properties dialog. Go to Tests Explorer > Object Repository. Right-click on an object and choose Properties.
    Find object ID
  2. 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.
    Test 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 WebUI 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 in script view
  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: as the value of the parameter.
    Navigate to a website in script view
  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 script view
  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 presents
  5. Close the browser: Add the Close Browser keyword and save your test case.
    Close browser script
You have successfully created a test case in Katalon Studio script view.