Setup and execution | Ranorex
Help CenterUser GuideWeb and mobile testing

iOS Testing

Learn how to automate your iOS app testing for different iPhone/iPad devices and languages. The following sections will explain how to set up an environment for iOS testing, how to create and execute a test and what to do if any problems occur. The iPhone/iPad app MiniKeePass is taken as an example of mobile application automation using Ranorex.
For more general information on mobile testing, feel free to refer to our mobile testing wiki.

In this chapter


    Before getting started with iOS test automation, it’s necessary to choose the connection type that suites your needs. The following overview helps you to find out which connection type will work best for you.

     USB  Wi-Fi
    Create tests
    Start/Stop App
    Install IPA
    Deploy (unattended)
    Note icon


    Note To make an iOS app testable with Ranorex, it is necessary to instrument the app. However, for a quick start you can take your first steps with the pre-instrumented KeePass app (see ⇢ Getting Started) that is provided for download.

    USB Requirements

    iTunes is necessary to establish a USB connection (debug mode and non-debug mode) because iTunes installs the USB driver on the Windows machine to connect to iOS devices.

    Network Requirements

    When choosing “Wi-Fi” as connection type, it is recommended that you have your system under test plugged into a power supply during test creation and execution. Additionally make sure that the system under test (the mobile devices) and the machine running the tests (where Ranorex is installed) are on the same network.

    Getting Started

    Although at the end of the day you might want to test your own mobile application, you can also take your first steps with the pre-instrumented MiniKeePass app. Please scan the QR code with your device and follow the link to the mobile download archive. From there the app can easily be installed.

    QR code for the mobile download archive

    Note icon


    In order to automate your own mobile app it needs to be instrumented guided by the instructions in the section ⇢ Instrumentation and Preparation.

    The following steps are needed to get started with the sample application:

    Connect your iOS device (Wi-Fi or USB). See Infrastructure for pros and cons.

    Go to the mobile download archive on your device using the QR Code above or the url

    Download and install the iOS service app and make sure it is started on your device.

    Download and install the sample app and initially start it to let the service app recognize it.

    Add the device in Ranorex using the endpoint list. You’ll find more details in the section Adding iOS device.

    Click the RECORD button in the Recording view.

    Note icon


    There is a small sample delivered with Ranorex Studio (can be found on the start page) that shows how the iOS MiniKeePass app can easily be tested with Ranorex.

    Create and Run an iOS Test

    After preparing the device and instrumenting the app, you can start creating your test by clicking on the RECORD button in the Recording view. The following dialog will appear.

    Interactive mobile test creation

    Click Create mobile test to proceed. You will see a short introduction how creating mobile tests works in Ranorex Studio. Once you’ve clicked through it, you will be prompted to choose a device and app:

    Select device and app

    By pressing the ‘Create’ button, the instrumented app will be automatically started on the mobile device and Ranorex Spy will be started on the desktop.

    To fill your repository with items and your recording with actions, two separate steps are necessary.

    Step 1: Track and add

    In this step, you will use Ranorex Spy to identify elements in your AUT and add them to your repository so you can assign actions to them.

    Click on a node in the element browser on the left to bring up a live preview of the associated UI in the bottom right.

    Mouse over the desired UI element in the preview, make sure it is covered with a red overlay, and click it. It’s now tracked and highlighted in the element tree. Alternatively, you can also browse through the element tree until you find the desired UI element.

    In the element tree, right-click the selected UI element and select one of the available Add to repository options from the context menu.

    The element is now available for use in your repository.

    Step 2: Drag and drop

    In this step, you will fill your recording with actions.

    Drag and drop the UI element you want to perform an action on from the repository to the action table.

    In the context menu that opens, select the desired action.

    Configure the action in the action table.

    Drag and drop

    Note icon


    You can also drag UI elements from the element tree to the action table directly. This works the same way as adding them to the repository beforehand and then dragging them to the action table.

    If your device is connected via USB you can also add a ‘Deploy iOS App’ action to automatically deploy the current version of your application under test for each test run. Choose the device, the file location of the app archive and the app id to enable automated deployment.

    Add ‘Deploy iOS App’ action

    After you’ve filled the recording module with actions as described above, the action table may look something like this:

    Action table

    Action #1 is a ‘Deploy iOS App’ action which deploys the given app to the selected device.

    Action #2 is a ‘Run Mobile App’ action which resets the instrumented app on the selected device.

    Action #3 is a Touch Event on a button. There are two different kinds of touch events recognized by Ranorex:

    • A normal ‘Touch’ which is equivalent to a mouse click on a desktop machine,
    • A ‘Long Touch’ which can be compared to a right click.
    Note icon


    The duration for both ‘Touch’ and ‘Long Touch’ can be defined in the properties pane. You can open this pane by clicking the context menu item ‘Properties’ on the ‘Touch Event’ action item.

    Action #4 is a ‘Set Value’ action, which is typically used for keyboard input.

    Action #5 is a ‘Mobile Key Press’ action. With a ‘Mobile Key Press’ action you can simulate the ‘Enter’ button on your devices keyboard.

    Action #6 is a ‘Wait For Not Exists’ action, which is useful for cases where an item indicates a loading process and the automation should continue after the item has disappeared.

    Action #7 is a ‘Validate’ action as was previously described.

    Action #8 is a ‘Get Value’ action, which can be used to write back an attribute value of a control to a variable for further processing.

    Action #9 is a ‘Report’ action, which is used to add information to the test report.

    Action #10 is an ‘Invoke Action’ which performs a scroll action on a table control to its index ‘0’. Invoke actions directly call the corresponding method of the selected adapter.

    You can use the invoke action to call user-defined methods or get and set user-defined members.
    To call such a user-defined method

    1. Type ‘CallMethod’ into the action name field of the invoke action
    2. Add the method name to the first argument field
    3. In the following argument field enter a value or choose a variable you want to pass to the method
    4. Repeat the previous step for all additional arguments

    To get or set a member, use ‘GetMember’ or ‘SetMember’ instead of ‘CallMethod’ as the action name.
    For further details about invoke action, have a look at ⇢ Invoking actions.

    User-defined methods can also be invoked from code in the same way. Here is a short example:

    string text = (string) repo.App.Text.Element.InvokeAction("CallMethod", "myCustomGetTextMethod");
    Dim text As String = DirectCast(repo.App.Text.Element.InvokeAction("CallMethod", "myCustomGetTextMethod"), String)

    Action #11 is a ‘Close Application’ action. ‘Close Application’ actions stop the selected application on the mobile device.

    Run Test

    Simply run your test as usual by pressing the ‘Run’ button. It will then be performed on your mobile device.