Apart from the Manual view, Katalon Studio also supports a Script view for users with programming skills to write test cases. The tool based on Groovy/Java background for editing test scripts in this view.
This tutorial will introduce you to a basic scenario of creating test cases using Katalon Studio’s Script view. You will also see how the import statements and built-in keywords feature work in making new test scripts.
- Open a browser
- Navigate to a website
- Perform certain control
- Validate if a control exists on the page
- Close the browser
Beginners guide to automate test case in Script view
Step 1: On the main toolbar, go to File > New > Test Case on the main toolbar.
Choose a name for the test case, then click OK.
Step 2: Switch to Script view after the new test case has been created. The test steps specified in the Manual view will be automatically translated to Groovy script in the Script view.
- Use the import statement in a test script to allow referencing to classes.
- All of Katalon’s default imported classes is displayed in the expanded section
- In each import statement, the name after “as” is an alias for the class. The alias for each class can be changed, and classes are essential for composing a test script.
Katalon Studio supports keyword-driven testing for your test cases. All keywords are categorized into WebUI, Mobile, and WebService packages accordingly. Select Ctrl + Space to view these packages and functions from the imported classes.
Step 3: In this scenario, create a Web application test script to utilize the Web UI built-in keywords. Enter the syntax (= WebUI) into the editor to use a built-in WebUI keyword.
Step 4: Enter a dot character (.) to see all the built-in keywords and their description for Web UI testing.
Step 5: Add the Open Browser keyword. It will open a browser and navigates to the URL you provided. The details for the selected keywords are also displayed in the popup screen, as shown below.
Step 7: Add the Click keyword. It represents the click action on a given object. A specified object is required for this action.
Step 8: To generate the syntax, you can either drag and drop the object to the test case editor or directly use the following syntax to refer to an object in Object Repository
Step 9: To find the ID of an Object, use the Properties dialog. For instance:
Step 10: Add the Verify Element Present keyword. It validates if a certain object is displayed on the executing browser. A specified object is required for this action.
Step 11: Add the Close Browser keyword and save your test case.
Step 12: Katalon’s documentation offers many API docs that are useful for your test scripts:
|Built-in Keywords||Common built-in keywords|
|Web UI Built-in Keywords||Common Web UI built-in keywords|
|Web Service Built-in Keywords||Common Web Service built-in keywords|
|Mobile Built-in Keywords||Common Mobile built-in keywords|
Step 13: To execute the test case, choose Run in the main toolbar.
Your test execution results are shown in the Log Viewer, as below:
This tutorial is to help you fully understand how to create a test case in Script view with Katalon Studio. To fully grasp the tool’s functionalities and advantages, explore other tutorials and download Katalon Studio at katalon.com.