Ranorex Help Center How can we help you?

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 generate 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.



Extended Information

After doing your first steps in mobile testing on iOS devices please find the following chapters providing detailed information on more advanced topics and testing scenarios

Infrastructure

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.



Record Replay Start/Stop App Install IPA Deploy (unattended)
USB

Wi-Fi



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 recording 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

QR code for the mobile download archive

Note 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:
  1. Connect your iOS device (Wi-Fi or USB). See Infrastructure for pros and cons.
  2. Go to the mobile download archive on your device using the QR Code above or the url bitly.com/mArchive.
  3. Download and install the iOS service app and make sure it is started on your device.
  4. Download and install the sample app and initially start it to let the service app recognize it.
  5. Add the device in Ranorex using the endpoint list. You'll find more details in the section Adding iOS device
  6. Start your mobile recording


Note 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.

Record and Run an iOS Test

After preparing the device and instrumenting the app, the recording can be started by choosing the device on which the test should be executed and the app to be tested.


Mobile recording with chosen target technology...




...device and app



By pressing the 'Record' button, a notification on the desktop will inform you, that actions will be recorded directly on the mobile device.

Record notification

Record notification



During the recording process, the action table of the Ranorex Recorder will give a good overview of the steps performed as the table is updated live.

Action table updates during recording process

Action table updates during recording process



During recording, it is possible to add validations using the Validation button. By pressing this button, a dialog will open where the element which is to be validated can be selected.

Select element to validate

Select element to validate



After choosing an element, the 'Validate Element' dialog will pop up. In this dialog, the attributes to be validated can be selected.

Choose attribute to validate

Choose attribute to validate



In addition to recording actions directly, it is also possible to add actions to the action table at a later time. This can be done by dragging a repository item to the action table and choosing the action which should be performed from the menu.

Adding actions manually

Adding actions manually



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

Add 'Deploy iOS App' action



After recording and adding actions manually, the action table might look something like the following.

Action table

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 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 Lesson 5: Ranorex Recorder - Additional Editing Options - Invoking User-Defined 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.

Stop Recording

After performing the test on the mobile device, the recording process can be stopped by pressing the 'Stop' button.

Stop recording

Stop recording



Run Test

After recording and altering the action table, the test can be executed on the mobile device by pressing the 'Run' button.