Creating test cases using Script Mode in Katalon Studio

This tutorial provides the steps needed to manually write a very basic automation test script using Katalon Studio. 

Make sure you already downloaded Katalon Studio at www.katalon.com

 

Scenario:

  • Open a browser
  • Navigate to a website
  • Click on certain control
  • Validate if the control exists on the page
  • Close the browser
 

Here’s how you can automate the above test scenario in Scrip view:

Step 1: Go to File > New > Test Case on the main toolbar. 

 Enter the test case name, and then click “OK.”

 

Step 2: Switch to the Script view after creating the new test case. Test steps specified in the Manual view are automatically translated to Groovy script in the Script view.

*Notes: 

  • The import statement in a test script allows referencing classes to be used.
  • You can see all the default imported classes by Katalon Studio by expanding the section.
  • An alias for the class is the name after “as” in each import statement. It can be changed for each class. These classes are essential for composing a test script.

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

 

Step 3: To make use of the Web UI built-in keywords, create a Web application test script. Put in syntax (= WebUI) into the editor to use a built-in WebUI keyword.

 

Step 4: Enter the dot character (.) to show all built-in keywords and their description for Web UI testing.

 

Step 5: Enter the Open Browser keyword. If the URL is provided, this keyword will open a browser and navigates to the previous specified URL. You will see the details for the selected keywords show up in the popup screen as shown below.

 

Step 6: Enter the Navigate To URL keyword. This keyword navigates to a specified URL. For now, enter the URL of Katalon Studio (katalon.com) as the value of the parameter.

 

Step 7: Enter Click keyword. This keyword represents the click action on a given object. You need to specify an object for this action.

 

Step 8: To generate the syntax, you can drag and drop the object to the test case editor or you can directly use the following syntax to refer to an object in Object Repository

findTestObject(‘{Object ID}’)

*Note: Object ID is the ID of that object in Katalon Studio.

 

Step 9: Finding an Object ID from its Properties dialog. For instance:

 

Step 10: To validate if a certain object is displayed on the executing browser, enter the Verify Element Present keyword. Same as the previous step, you need to associate this keyword with an object.

 

Step 11: Add the Close Browser keyword and save your test case.

 

Step 12: These API docs would be useful to you while working with scripts:

ClassDescriptionDescription
Built-in KeywordsList of common built-in keywords
Web UI Built-in KeywordsList of Web UI built-in keywords
Web Service Built-in KeywordsList of Web Service built-in keywords
Mobile Built-in KeywordsList of Mobile built-in keywords
 

Step 13: To execute the test case, click “Run” in the main toolbar.

The test execution results are shown in the Log Viewer, as below:

Congratulations! You have finished your first automation script in Katalon Studio. Stay tuned for the next tutorial: Creating test cases using Manual Mode.


>>> Checkout Katalon Tutorial List <<<



⇓ Subscribe Us ⇓


If you are not regular reader of this website then highly recommends you to Sign up for our free email newsletter!! Sign up just providing your email address below:


 

Check email in your inbox for confirmation to get latest updates Software Testing for free.


  Happy Testing!!!
 

Leave a Comment

Share This Post