Use iOS 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.

Perfecto Force Touch command

Perfecto's Touch command supports the 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 by holding down the (keyboard) Ctrl and Alt keys together with tapping the screen with mouse. This will be interpreted as a forceful tapping of the screen at the coordinates.

Legacy | Native automation

For users of Perfecto's Native Automation use the Touch function (in the Functions tab) to perform the 3D Touch.

  1. Open the Advanced Parameters

  2. Select the Force value in the Operation mode parameter.

  3. Provide either:

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

    • Coordinates as percentages - to allow for different screen resolutions.

Note:

The coordinates on the screen start from <0, 0> in the upper left corner of the screen and are given in pixels.

Alternatively, use the 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);

Supported platforms

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

Limitations

  • 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 device the following menu items are not usable: "Mark My Location", "Send My Location" and "Search Nearby" button. These 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.