DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

The software you build is only as secure as the code that powers it. Learn how malicious code creeps into your software supply chain.

Apache Cassandra combines the benefits of major NoSQL databases to support data management needs not covered by traditional RDBMS vendors.

Generative AI has transformed nearly every industry. How can you leverage GenAI to improve your productivity and efficiency?

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Related

  • How to Test QR Codes in Your Applications
  • JUnit 5 Custom TestListeners
  • Getting Started With Microsoft Tool Playwright for Automated Testing
  • Injecting Chaos: Easy Techniques for Simulating Network Issues in Redis Clusters

Trending

  • Driving DevOps With Smart, Scalable Testing
  • Creating a Web Project: Caching for Performance Optimization
  • Agentic AI and Generative AI: Revolutionizing Decision Making and Automation
  • Next-Gen IoT Performance Depends on Advanced Power Management ICs
  1. DZone
  2. Testing, Deployment, and Maintenance
  3. Testing, Tools, and Frameworks
  4. Creating Test Cases Using Script Mode With Katalon Studio

Creating Test Cases Using Script Mode With Katalon Studio

This tutorial will show you how to programmatically write automated test cases in script view in Katalon Studio, using Java and Groovy.

By 
Oliver Howard user avatar
Oliver Howard
·
Sep. 28, 17 · Tutorial
Likes (10)
Comment
Save
Tweet
Share
10.5K Views

Join the DZone community and get the full member experience.

Join For Free

In addition to the manual view, Katalon Studio allows expert users to programmatically write automation test in the script view of test cases. Users with a Groovy/Java background can easily edit test scripts in this view.

This tutorial walks you through the steps needed to manually write a very basic automation test script using Katalon Studio. After going through this article, you will understand and be able to use import statements and built-in keywords to compose test scripts. It’s recommended that you should have some basic scripting background, preferably using Groovy, to efficiently use the scripting capability.

Given a sample test case with the following steps:

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

Follow these steps to automate the above test scenario in script view:

Select File > New > Test Case from the main menu to create a test case. Provide the name for the new test case, then click OK.

new test case Katalon Studio

Once a new test case is created, you switch to the script view. Test steps specified in the manual view are automatically translated to Groovy script in the script view.

Script mode Katalon Studio

The import statement in a test script allows referencing to classes to be used. 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.

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

In this scenario, you will create a Web application test script, so you can make use of the Web UI built-in keywords. To use a built-in WebUI keyword, enter WebUI. into the editor.

After entering the dot character (.), all built-in keywords and their description for WebUI testing appear as below:

Content Assist Dialog Katalon Studio

Select the Open Browser keyword. This keyword opens a browser and navigates to the specified URL, if provided. The detail for a selected keyword is shown in a popup screen.

Open Browser Katalon Studio

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 for the parameter.

Navigate URL keyword Katalon Studio

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

Click keyword Katalon Studio

Use the following syntax to refer to an object in the Object Repository (alternatively, you can drag and drop the object to test case editor to generate the syntax):

findTestObject('{Object ID}')

where Object ID is the ID of that object in Katalon Studio.

You can find an object’s ID from its Properties dialog. For example:

Object ID Properties

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 present

Add the Close Browser keyword and save your test case.

Close Browser keyword

The following API docs are useful when working with scripts:

Class DescriptionDescription
Builtin Keywords List of common built-in keywords
WebUI Builtin Keywords List of Web UI built-in keywords
Web Service Builtin Keywords List of Web Service built-in keywords
Mobile Builtin Keywords List of Mobile built-in keywords

Congratulations! You have finished your first automation script in the Groovy language. Click on Run in the main toolbar to execute the test case.

Run Katalon Studio

Katalon Studio should be able to execute the script of the test case. Test execution results are shown in Log Viewer as below:

Test execution Dialog

For more tutorials, please visit the Katalon Studio website!

Testing Katalon Studio Test case Object (computer science) Web Service

Published at DZone with permission of Oliver Howard. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • How to Test QR Codes in Your Applications
  • JUnit 5 Custom TestListeners
  • Getting Started With Microsoft Tool Playwright for Automated Testing
  • Injecting Chaos: Easy Techniques for Simulating Network Issues in Redis Clusters

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!