[Mobile] Create and Run iOS Test Case

This tutorial demonstrates how to create iOS tests with Katalon Studio using Record and Playback.

Go through the "Recording a scenario of counting down Green Tea making time via the Coffee Timer.ipa application" to get familiar with these features. The basic steps are:

  1. Launch Coffee Timer.ipa on the device.
  2. Tap on Green Tea.
  3. Tap on Start.
  4. Tap on Stop.

Coffee Timer.ipa and sample project code are available here.

Create and Run your first iOS test case

Create New Project

  1. In the Test Explorer on the sidebar > click New Project.

  2. In the displayed New Project dialog:

    • Input project Name.

    • In project Type > select Mobile.

    • In Project > select Sample iOS..., the Repository URL is filled automatically.

    • Browse a Location to store your project > click OK.

Record

  1. On the main toolbar, click on the Record Mobile icon and select your device type. For example, iOS Devices.

  2. In the displayed Mobile Recorder dialog, specify the information at the Configurations section:

    • Device Name: select one of your connected iOS devices.
    • Start with: select Application File in the drop-down list.
    • Application File: Browse Coffee Timer.ipa.
  3. Click Start to begin recording your test case:

    • Wait until the AUT is launched.
    • The Device View and All Objects are ready for you to interact with the application.
  4. On the Device View > click Green Tea, Katalon Studio selects Green Tea in All Objects correspondingly.

  5. Once Green Tea is selected, Tap is enabled in Available Actions > click Tab, the tap action is performed as follows:

    • The Device View is rendered with newly displayed elements.

    • In Recorded Actions, Tap is added to the list of recorded steps.

    • In Captured Objects, Green Tea is captured with its properties.

    Note

    • The essential property of an object is its locator strategy and value. The default locator is a unique value in detecting that object. Katalon Studio 7.6+ fully supports selector strategies supported by Appium.

    • If you prefer another locator strategy, select your prefered one and generate a new locator > click Highlight to see if your newly updated locator can detect the target object on its screen correctly.

  6. Similarly in Device View, click Start > click Tap in Available Actions.

    You can see another tap action is added to the list of Recorded Actions and Captured Objects.

  7. In Device View, click Stop > click Tap in Available Actions.

  8. Click on the Stop button above the CONFIGURATIONS section to close the application and finish recording.

    After finishing recording the desired interactions with the AUT, click Save script to save the captured objects.

    In the displayed Folder Browser dialog, create a new folder or select an existing folder in Object Repository > click OK.

  9. You can add the recorded test steps to a new test case, append to or overwrite an existing one.

Playback

To playback the recorded scenario:

  1. Select the test case where you saved the recorded actions.

  2. On the main toolbar, select iOS device on the drop-down list next to Run.

  3. In the displayed iOS Devices dialog, select a device > click OK.

Katalon Studio executes the iOS test with the recorded steps accordingly.

View the test case in Script mode.

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 static com.kms.katalon.core.testobject.ObjectRepository.findWindowsObject
import com.kms.katalon.core.checkpoint.Checkpoint as Checkpoint
import com.kms.katalon.core.cucumber.keyword.CucumberBuiltinKeywords as CucumberKW
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.testdata.TestData as TestData
import com.kms.katalon.core.testobject.TestObject as TestObject
import com.kms.katalon.core.webservice.keyword.WSBuiltInKeywords as WS
import com.kms.katalon.core.webui.keyword.WebUiBuiltInKeywords as WebUI
import com.kms.katalon.core.windows.keyword.WindowsBuiltinKeywords as Windows
import internal.GlobalVariable as GlobalVariable
import org.openqa.selenium.Keys as Keys

Mobile.startApplication('/Users/thuyngo/Desktop/Project/iOS/App/Coffee Timer 2021-01-27 16-49-52/Apps/Coffee Timer.ipa', true)

Mobile.tap(findTestObject('Object Repository/XCUIElementTypeStaticText - Green Tea (1)'), 0)

Mobile.tap(findTestObject('Object Repository/XCUIElementTypeButton - Start (2)'), 0)

Mobile.tap(findTestObject('Object Repository/XCUIElementTypeButton - Stop (1)'), 0)

Mobile.closeApplication()

Next: Execute and Debug a Test Case.

Previous: [Mobile] iOS Setup.

See also:

Feedback