iOS | Use 3D Touch

iOS 3D Touch is designed to allow applications to support a new level of interaction with the user. An application that uses 3D touch performs different actions based on the level of pressure exerted by the user when tapping the screen. This implies that when your test activates the 3D functionality, you will need a mechanism that provides different levels of touch intensity when "tapping" the screen.

Important: This document includes references to a third-party product, Apple iOS devices. The user interface and usage of third-party products are subject to change without notice. For the latest published information about Apple iOS devices, see Apple Support.

Supported platforms

Perfecto's 3D Touch support is available for all iOS devices (iPhone 6S or later) running iOS 10.3 or later, on XCUITest framework, that support the necessary hardware.

Restrictions

  • On iOS 11, using 3D Touch in SpringBoard is unstable and may cause the device to become unresponsive after an action (usually released by just pressing the Home button). This is a limitation stemming from Apple’s API.

  • When using 3D touch on iOS devices, the following menu items are not usable: Mark My Location, Send My Location, and Search Nearby. These options cannot be clicked manually or automatically. This limitation stems from Apple's implementation.

  • 3D Touch commands cannot be sent using the Appium driver.performTouchAction(touchAction) method.

  • When executing a script using the Appium value for the automationName capability on iOS 11 or on supported iOS 10 devices with the XCUITest value for the automationName capability, coordinates retrieved from objects will not be executed correctly using Perfecto’s Touch command. The reason is that Appium bases the screen size on UI points, whereas in Perfecto, the screen size is based on rendered pixels.

    For an explanation about the difference, see: https://www.paintcodeapp.com/news/iphone-6-screens-demystified.

Perfecto Force Touch command

Perfecto's Touch command supports 3D Touch.

Prerequisites: The device must have Force Touch/3D Touch and it must be enabled. To check if 3D Touch is enabled, go to Settings > General > Accessibility > 3D Touch = On.

Manual Testing view

For manual testers, perform a 3D Touch action by holding down the (keyboard) Ctrl and Alt keys together while tapping the screen with the mouse. This will be interpreted as forcefully tapping the screen at the coordinates.

Legacy | Native automation

For users of Perfecto's Native Automation tool, use the Touch function (on the Functions tab) to perform 3D Touch, as follows:

  1. Open the Advanced Parameters dialog box.

  2. In the Operation mode parameter, select the Force value.

  3. Provide one of the following:

    • Exact <X, Y> coordinates where to tap the screen.

    • Coordinates as percentages to allow for different screen resolutions.

The coordinates on the screen start from <0, 0> in the upper left corner of the screen and are given in pixels. Alternatively, use Record mode and create the action interactively, as above.

Selenium/Appium automation scripts

To activate the Touch function in 3D Touch mode, use the following (Java) sample code as a basis:

Copy
Map<String, Object> parms = new HashMap<>();
                parms.put("location", "80,270");
                parms.put("operation", "force")
            Object res = driver.executeScript("mobile:touch:tap", parms);