Table of contents
1.
Introduction
2.
Create and Run iOS Test Case
2.1.
Create a new project
2.2.
Record a new Test Case
2.3.
Run the recorded test case
3.
Create and Run Android Test Case
3.1.
Create New Project
3.2.
Record
3.3.
Playback
4.
Frequently Asked Questions
4.1.
What is Katalon Studio used for?
4.2.
Is Katalon Studio better than Selenium?
4.3.
Is Katalon Studio still free?
4.4.
What language does Katalon use?
4.5.
Is Katalon suitable for automation?
5.
Conclusion
Last Updated: Mar 27, 2024

Create and Run iOS and Android Test Case In katalon studio

Author Aditi
0 upvote
Career growth poll
Do you think IIT Guwahati certified course can help you in your career?

Introduction

Have you ever worked with any automated testing software tools? 

This article is focused on one of these automated testing software tools, i.e., Katalon Studio. Katalon Studio is built on the open-source Selenium and Appium automation frameworks. It has a specialized IDE interface for API, mobile, web, and desktop application testing. 

Let's dive into the article to learn more about Test cases in Katalon Studio.

Create and Run iOS and Android Test Case In katalon studio

Create and Run iOS Test Case

In this section of the article, demonstrations of steps for creating test cases are given. These are for iOS. This is done using Mobile Record Utility with Katalon Studio. After all, the steps, run the test cases, which are recorded.

In the following example, we will record the Coffee Timer application actions for testing:

  • Launch this application on the device.
  • Click on Green Tea.
  • Click on Start.
  • Click on Stop.

Create a new project

  • Go to file ->New -> New Project to create a new project.
  • Fill the New Project dialog box displayed as shown below:
create a new project
  • Click OK after the project details are filled. A new project will be opened, which will be a mobile project.

Record a new Test Case

  • Click Record Mobile on the main toolbar. Select the device type accordingly. For example, here, we choose the option iOS Devices.
  • Specify the details in the Configurations section, which is displayed in the Mobile Recorder dialog. Information is given below:-
  • To record your test case, click on Start. Upon launching the application under test (AUT), you can see the following:
    • Device View: This part displays the AUT start page. You can interact with this section in a similar way as in the iOS device's reality.
    • All Objects: This part displays all current view objects in the Device View section.
  • We will click on Green Tea in the section Device View. Katalon Studio will select objects of Green Tea in the section All Objects correspondingly.
  • We click the action Tab after Green Tea is selected. This action is present in the Available Action section. We see:
    • The countdown is displayed in the section Device View for Green Tea.
    • The Tap action is immediately added by Katalon to the list of steps recorded in the Recorded Actions tab.
    • Katalon records the Green Tea object's properties and adds them to the tab Captured Objects.
  • In the section Device View, click Start. Click Tab, which is present in the section Available Actions. Katalon automatically adds another Tap action and the Stop object properties to the Recorded Actions and the Captured Objects tab.
  • Click on Save script. A dialog box opens, asking you to save captured objects. It saves it in the Katalon Studio Object Repository. You can select an existing folder or create a new folder in the Object Repository. Click OK.
  • A dialog box opens. It provides you with different ways to save your recorded test. They are as follows:
record a new test case

Run the recorded test case

Follow the following steps to execute the recorded steps:-

  • Choose the test case. It is from the recorded actions.
  • Choose the iOS device on the main toolbar. It is present next to Run in the dropdown list.
  • Choose Xcode simulator or iOS device in the iOS Devices dialog displayed. Click on OK after that.
  • The iOS test is run by Katalon Studio by the recorded steps.

 

Test case view in Script mode:-

import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mbl
import com.kms.katalon.core.model.FailureHandling as ErrorHandler
import com.kms.katalon.core.testcase.TestCase as Test_Case
import com.kms.katalon.core.testdata.TestData as Test_Data
import com.kms.katalon.core.testobject.TestObject as Test_Object
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSKW
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as Web_UI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as WindowsKW
import internal.GlobalVariable as Global_Variable
import org.openqa.selenium.Keys as Selenium_Keys

Mbl.startApplication('/Users/thuyngo/Desktop/Project/iOS/App/Coffee Timer 2022-12-1 26-59-62/Apps/Coffee Timer.ipa', true)
Mbl.tap(findTestObject('Object Repository/XCUIElementTypeStaticText - Green Tea (1)'), 0)
Mbl.tap(findTestObject('Object Repository/XCUIElementTypeButton - Start (2)'), 0)
Mbl.tap(findTestObject('Object Repository/XCUIElementTypeButton - Stop (1)'), 0)
Mbl.closeApplication()
You can also try this code with Online Javascript Compiler
Run Code

Create and Run Android Test Case

In this article section, you will learn a step-by-step tutorial to create tests for Android. You will do this by using Record and Playback in Katalon Studio.

Read the following:-

Recording a message-sending scenario with the application APIDemos.apk.

This will be the scenario to become familiar with the features of Katalon studio. The basic steps are given below:-

  • Launch the APIDemos.apk application on the device.
  • Click on OS.
  • Click on SMS Messaging.
  • Enter a message and a phone number.
  • Click on Send.

Create New Project

  • Click New Project on the sidebar of Text Explorer.
  • A New Project dialog box will appear. Follow the below steps:-
    • Enter the project Name.
    • Select Mobile in the Project Type.
    • Choose Sample Android… in the Project. The Repository URL will get filled automatically.
    • Click OK after browsing a location for storing your project.

Record

  • Click on Record Mobile in the main toolbar. Now, choose Android Devices.
  • A dialog box of Mobile Recorder will open. Enter the information in the section Configurations:-
    • Device Name: Choose any one of your Android devices which are connected.
    • Start with: In the dropdown list, choose Application File.
    • Application File: Search APIDemos.apk.
  • Begin your test case recording by clicking on Start:
    • Wait till AUT is launched.
    • You can interact with the app using the Device View and All Objects.
  • Click OS in the Device View. Katalon Studio will select the OS correspondingly in All Objects.
  • Click Tab in Available Actions after OS is selected. The tap should be enabled. Now, the actions of tap will be performed.
  • In the same way, click on SMS Messaging in Device View. Then in Available Actions, click Tap. Another tap action is seen to be added to the Captured Objects and Recorded Actions list.
  • Select the text input area next to Recipient in Device View. Click on Set Text in the Available Actions. Text input dialog opens. Enter the phone number and then click OK. Phone numbers will be filled in the Device View text field.
  • Select the text input area next to the Message Body in Device View. Click on Set Text in the Available Actions. Text input dialog opens. Enter the message and then click OK. The message will be set in the Device View text field. Also, in the Recorded Actions, Set Text will get added.
  • Click on Send and then on Tap in Device View Available Actions.
  • To finish the recording and close the application, click on the Stop button. This button is present above the section CONFIGURATIONS. After finishing this with AUT, click on the Save script to save captured objects. In the Folder Browser dialog box, you can select an existing folder or create a new one. This is done by clicking on the Object Repository and then clicking OK.
  • A recorded test step can be added to a new test case, overwritten, or appended to an existing test case by you.

Playback

Follow the steps below to playback the scenario (that is recorded):-

  • Open the location of recorded actions that are saved. Choose the test case.
  • Select Android device on the main toolbar. It is present next to Run in the dropdown list.
  • An Android Devices dialog box will appear. Choose a device and then click OK.

The mobile test will be run by the Katalon Studio accordingly, with the steps recorded.

 

Test case view in Script mode:-

import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.configuration.RunConfiguration
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mbl
import com.kms.katalon.core.model.FailureHandling as ErrorHandler

Mbl.startApplication(RunConfiguration.getProjectDir() + '/APIDemos.apk', true)
Mbl.tap(findTestObject('Object Repository/APIDemo/android.widget.Button - OK'), 0, ErrorHandler.OPTIONAL)
Mbl.tap(findTestObject('Object Repository/APIDemo/android.widget.TextView - OS'), 0)
Mbl.tap(findTestObject('Object Repository/APIDemo/android.widget.TextView - SMS Messaging'), 0)
Mbl.setText(findTestObject('Object Repository/APIDemo/android.widget.EditText'), '+91 9123456789', 0)
Mbl.setText(findTestObject('Object Repository/APIDemo/android.widget.EditText (1)'), 'This is Test Case Program in Katalon Studio - Coding Ninjas', 0)
Mbl.tap(findTestObject('Object Repository/APIDemo/android.widget.Button - Send'), 0)
Mbl.closeApplication()
You can also try this code with Online Javascript Compiler
Run Code

Frequently Asked Questions

What is Katalon Studio used for?

Katalon is used to create and reuse automated test scripts for UI without coding. It allows running automated tests of UI elements. It can be launched on Microsoft Windows, macOS, and Linux.

Is Katalon Studio better than Selenium?

Selenium is faster than Katalon studio. The reason behind it is the scripting language. Katalon uses Groovy, which is built on Java. So it has to load more libraries, test objects, etc. The difference in performance and speed will be noticeable if the test is very long.

Is Katalon Studio still free?

The free plan of Katalan Studio is suitable for individuals and small teams. The Premium plan is best for large teams or SMBs who need different test results and have production-grade testing workloads. 

What language does Katalon use?

Katalon Studio uses Groovy, a language built on top of Java. It has to load many libraries for parsing test data, test objects, and logging.

Is Katalon suitable for automation?

Katalon is a good tool for test automation, both for APIs and Web Pages. 

Conclusion

This complete article has helped us to learn about all the concepts and steps for creating and running our test cases. We have learned how to create and run test cases for iOS and Android using Katalon Studio.

We hope this blog has helped you enhance your Mobile testing with Katalon Studio knowledge. Check out our articles to learn more about the introduction to API and its usageWeb API introduction, and real-world API. Practice makes a man perfect. To practice and improve yourself in the interview, you can check out Top 100 SQL problemsInterview experienceCoding interview questions, and the Ultimate guide path for interviews.

Do upvote our blog to help other ninjas grow. Happy Coding!

thank you
Live masterclass