Skip to main content

Utilizing sample mobile tests projects

Utilizing sample mobile tests projects in Katalon Studio is the fastest way to learn the ropes of building a mobile tests project from scratch. You can also use a sample project and retrofit it into a mobile tests project that shares a similar scope.

Sample iOS mobile project in Katalon Studio

This sample demonstrates iOS testing fundamentals in Katalon Studio.

The application under test is the Coffee Timer application, which contains different timers for different coffee types.

Requirements

Open the sample iOS test project

To open the iOS sample project, in Katalon Studio, go to File > New Sample Project > Sample iOS Mobile Tests Project.

Open iOS sample project

Alternatively, you can download the iOS sample project from our GitHub repository: iOS sample.

Prepare the iOS application file

The Coffee Timer application located in the App folder of this sample project is pre-built and signed by the Katalon team to only run on Katalon devices.

The sample coffee timer application

As part of the iOS development procedure, to execute the sample test cases with your iOS devices, you need to build and sign the Coffee Timer application for your iOS devices.

For iOS simulators

To execute the sample test cases with Xcode simulators, you need to prepare an .app file.

  1. Open the Coffee Timer.xcodeproj project file with Xcode. To find the project save location, go to <your-project-folder>/App/Your-First-iOS-App>Coffee Timer. Double-click the Coffee Timer.xcodeproj file to open the file.
    Open Coffee Timer Xcode project

  2. Choose one of the iOS simulators to launch the apps.
    Choose the iOS simulators

  3. To build the .app file, click Product > Build.

    When the build is finished, to find the .app file, go to ~/Library/Developer/Xcode/DerivedData/Coffee Timer/Build/Products/Debug-iphonesimulator/Coffee Timer.app.

    Note:

    To quickly search for the DerivedData folder, copy and paste the following path ~/Library/Developer/Xcode/DerivedData into the Spotlight Search.

  4. Copy and paste the Coffee Time.app file into the App folder of the sample project. Katalon will use this file to start the Coffee Timer application.

For real iOS devices

To execute mobile testing with real iOS devices, you need to prepare an .ipa file.

  1. Open the Coffee Timer.xcodeproj project file with Xcode. To find the project save location, go to <your-project-folder>/App/Your-First-iOS-App>Coffee Timer. Double-click the Coffee Timer.xcodeproj file to open it.
    Open Coffee Timer Xcode project

  2. Select a registered iOS device to launch the apps.
    Choose the iOS device

  3. In the General tab, set the deployment iOS version and select the device type in the Deployment Info section.
    Choose the iOS system

  4. Switch to the Signing & Capabilities tab, check the Automatically manage signing box, then choose the team that has your device registered in the Apple Developer Portal.
  5. To build the .ipa file, click Product > Build.
  6. To archive the .ipa file, click Product > Archive. If the archive builds successfully, it appears in the Archives organizer.
  7. To open the Archives organizer, choose Window > Organizer and click Archives.
  8. Select the archive you want to export, then click Distribute App and follow the instructions to get the .ipa file. Here, we choose a development provisioning profile to export the Coffee Timer.ipa file.
    Build the Coffee Timer.ipa

  9. Verify the .ipa file.
    1. Navigate to Window > Devices and Window > Simulators in Xcode.
    2. Choose your device from the Devices list.
    3. Click Add (+) to browse the .ipa file.

    Add the .ipa file to Xcode devices

    Once installed successfully, the application appears in the Installed Apps.

    Add the .ipa file to Xcode devices

  10. Put the Coffee Time.ipa file into the App folder of the sample project. Katalon will use this file to start the Coffee Timer application.

iOS sample project components

Test cases

There are two test cases for different purposes:

The Mexican Coffee Timer test case starts and stops the timer for making a Mexican coffee. In this example, we run the test case with a real iOS device.

  • Start the Coffee Timer.ipa application. Here, we use the sample.Common.startApplication custom keyword to run the application.
  • Tap Mexican. We set the timeout for 0 seconds.
  • Tap Start. We set the timeout for 0 seconds.
  • Tap 3:19. We set the timeout for 0 seconds.
  • Tap Stop. We set the timeout for 0 seconds.
  • Tap Back. We set the timeout for 0 seconds.
  • Close the application.

In Script view, the test script for the test case is as follows:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

CustomKeywords.'sample.Common.startAppliucation'()

Mobile.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Mexican'), 'Mexican')

Mobile.tap(findTestObject('XCUIElementTypeStaticText - Mexican'), 0)

Mobile.tap(findTestObject('XCUIElementTypeButton - Start'), 0)

Mobile.tap(findTestObject('XCUIElementTypeStaticText - 319'), 0)

Mobile.tap(findTestObject('XCUIElementTypeButton - Stop'), 0)

Mobile.tap(findTestObject('XCUIElementTypeButton - Back'), 0)

Mobile.closeApplication()

The Verify the main list test case verifies the list of the coffee name in the application. In this example, we run the test case with a real iOS device.

  • Start the Coffee Timer.ipa application. Here, we use the sample.Common.startApplication custom keyword to run the application.
  • Verify if the application is showing the Mexican item.
  • Verify if the application is showing the Colombian item.
  • Verify if the application is showing the Coffees item.
  • Close the application.

In Script view, the test script for the test case is as follows:

import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.checkpoint.CheckpointFactory as CheckpointFactory
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as MobileBuiltInKeywords
import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
import com.kms.katalon.core.model.FailureHandling as FailureHandling
import com.kms.katalon.core.testcase.TestCase as TestCase
import com.kms.katalon.core.testcase.TestCaseFactory as TestCaseFactory
import com.kms.katalon.core.testdata.TestData as TestData
import com.kms.katalon.core.testdata.TestDataFactory as TestDataFactory
import com.kms.katalon.core.testobject.ObjectRepository as ObjectRepository
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WSBuiltInKeywords
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUiBuiltInKeywords
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import internal.GlobalVariable as GlobalVariable

CustomKeywords.'sample.Common.startAppliucation'()

Mobile.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Mexican'), 'Mexican')

MobileBuiltInKeywords.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Colombian'), 'Colombian')

MobileBuiltInKeywords.verifyElementText(findTestObject('Spy/XCUIElementTypeStaticText - Coffees'), 'Coffees')

Mobile.closeApplication()

Test suites

To access the test suite in this project, in the Test Explorer panel, go to the Test Suites > Smoke Tests folder. This test suite combines the two test cases as demoed earlier.

Test Suites

Execute iOS tests

To execute a test case or a test suite in the sample project, follow these steps:
  1. Select the test case/test suite you want to execute.
  2. On the main toolbar, click on the Run dropdown menu and select iOS as the device type.
    Execute iOS

  3. In the displayed iOS Devices dialog, select an iOS device or Xcode simulator, then click OK.
    Choose iOS device

  4. Observe the test result in the Log Viewer tab.
    View results

Sample Android mobile project in Katalon Studio

This sample demonstrates Android testing fundamentals in Katalon Studio.

The application under test (AUT) is the APIDemos.apk application.

Requirements

  • Android setup. To learn more about setting up Android devices, you can refer to this document: [Mobile] Android Setup.

Open the sample Android test project

To open the Android sample project, in Katalon Studio, go to File > New Sample Project > Sample Android Mobile tests Project. Katalon Studio will automatically detect and ask you to install Android SDK if your current machine does not have it or your Android SDK is not located at the default folder: ~/.katalon/tools/android_sdk.Open Android sample project

Alternatively, you can download the Android sample project from our GitHub repository: Android sample.

Android sample project components

Profiles

To open the execution profile, go to Profiles > default.

Open execution profile in the sample Android project

You can create and save all global variables in the execution profile. They can be used across test cases in your project. To learn more about execution profile, you can refer to this document: Execution profile.

Katalon creates four global variables in this sample project as follows:

NameValue
G_timeout10
G_NotificationMessageYour message has been sent. View message
G_AndroidAppandroidapp/APIDemos.apk
G_ShortTimeOut5

Test cases

To access test cases in this project, go to the Test Cases folder in the Test Explorer panel.

Sample test cases

There are two test cases for different purposes:

  1. The Verify Correct Alarm Message test case is to verify if we can get the correct displayed message.

    • Start the APIDemos.apk application. Here, the location of the AUT is under the <sample-project-folder>/androidapp folder. We use the following sample code to identify the absolute path to the application:

      /*Get full directory's path of android application*/
      def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.G_AndroidApp, RunConfiguration.getProjectDir())

      /*Start the AUT*/
      Mobile.startApplication(appPath, false)
    • Tap App. We set the timeout for 10 seconds.
    • Tap Activity. We set the timeout for 10 seconds.
    • Tap Custom Dialog. We set the timeout for 10 seconds.
    • Verify if the text displaying on the App, Activity, and Custom Dialog dialog is correct.

      Verify Correct Alarm Message

      In Script view, the test script for the test case is as follows:

      import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
      import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
      import internal.GlobalVariable as GlobalVariable
      import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
      import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
      import com.kms.katalon.core.util.internal.PathUtil as PathUtil
      import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
      import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
      import static com.kms.katalon.core.checkpoint.CheckpointFactory.findCheckpoint
      import com.kms.katalon.core.model.FailureHandling as FailureHandling
      import com.kms.katalon.core.testcase.TestCase as TestCase
      import com.kms.katalon.core.testdata.TestData as TestData
      import com.kms.katalon.core.testobject.TestObject as TestObject
      import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint

      Mobile.comment('Story: Verify correct alarm message')

      Mobile.comment('Given that user has started an application')

      'Get full directory\'s path of android application'
      def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.G_AndroidApp, RunConfiguration.getProjectDir())

      Mobile.startApplication(appPath, false)

      Mobile.comment('And he navigates the application to Activity form')

      Mobile.tap(findTestObject('Alarm Message/android.widget.TextView - App'), 10)

      Mobile.tap(findTestObject('Alarm Message/android.widget.TextView - Activity'), 10)

      Mobile.comment('When he taps on the Custom Dialog button')

      Mobile.tap(findTestObject('Alarm Message/android.widget.TextView - Custom Dialog'), 10)

      'Get displayed message on the dialog'
      def message = Mobile.getText(findTestObject('Application/App/Activity/Custom Dialog/android.widget.TextViewCustomDialog'),
      10)

      Mobile.comment('Then the correct dialog message should be displayed')

      Mobile.verifyEqual(message, 'Example of how you can use a custom Theme.Dialog theme to make an activity that looks like a customized dialog, here with an ugly frame.')

      Mobile.closeApplication()
  2. The Verify Last Items In List test case is to verify whether we can identify the correct last item in the list.

    • Start the APIDemos.apk application. Here, the location of the AUT is under the <sample-project-folder>/androidapp folder. We use the following sample code to identify the absolute path to the application:

      /*Get full directory path of the android application*/
      def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.G_AndroidApp, RunConfiguration.getProjectDir())

      /*Start the AUT*/
      Mobile.startApplication(appPath, false)
    • Tap Graphics. We use the G_Timeout global variable as the timeout value.
    • Scroll to the Xfermodes item.
    • Verify if the current screen shows Xfermodes text after scrolling.

      Verify Last Items In List

      In Script view, the test script for the test case is as follows:

      import static com.kms.katalon.core.testcase.TestCaseFactory.findTestCase
      import static com.kms.katalon.core.testdata.TestDataFactory.findTestData
      import static com.kms.katalon.core.testobject.ObjectRepository.findTestObject
      import internal.GlobalVariable as GlobalVariable
      import com.kms.katalon.core.configuration.RunConfiguration as RunConfiguration
      import com.kms.katalon.core.mobile.keyword.MobileBuiltInKeywords as Mobile
      import com.kms.katalon.core.util.internal.PathUtil as PathUtil

      Mobile.comment('Story: Verify correct alarm message')

      Mobile.comment('Given that user has started an application')

      'Get full directory\'s path of android application'
      def appPath = PathUtil.relativeToAbsolutePath(GlobalVariable.G_AndroidApp, RunConfiguration.getProjectDir())

      Mobile.startApplication(appPath, false)

      Mobile.comment('And he navigates the application to Graphics form')

      Mobile.tap(findTestObject('Last Items/android.widget.TextView - Graphics'), GlobalVariable.G_Timeout)

      Mobile.comment('When he scroll to Xfermodes text')

      Mobile.scrollToText('Xfermodes')

      Mobile.comment('Then the current screen should show Xfermodes text after scrolling')

      'Get item\'s label'
      def itemText = Mobile.getText(findTestObject('Last Items/android.widget.TextView - Xfermodes'), GlobalVariable.G_Timeout)

      Mobile.verifyEqual(itemText, 'Xfermodes')

      Mobile.closeApplication()

Test suite

To access the test suite in this project, in the Test Explorer panel, go to Test Suites > Regression Tests folder. This test suite combines the two test cases shown above.

Test Suites

Execute Android tests

To execute a test case or a test suite in the sample project, follow these steps:
  1. Select the test case or the test suite you want to execute.
  2. On the main toolbar, click on the Run dropdown menu and select Android as the device type.
    Execute the selected test

  3. Select your device from the Android Devices list. Click OK.
    Select the Android device

  4. Observe the test result in the Log Viewer tab.
    View results