Image Blog Perfecto Automates Face id Flows for Iphone x
November 16, 2017

Perfecto Automates Face ID Flows for iPhone X

Mobile Application Testing

Prior to the iPhone X launch, many people doubted the premise of leveraging face ID as the exclusive biometric authentication measure. Post launch, the Face ID feature is widely used, and Apple is planning to transition all future devices to this authentication method.

For mobile brands, Face ID impacts user adoption and application usage tremendously. It streamlines key transactions in the user flow to a degree that was not possible before. Face ID can streamline in-app purchases, beyond logging into the app, for example, while playing a game. Prior to the usage of biometric sensors in apps, it would have been cumbersome for users to enter their credentials in the middle of a game. Further, users get a stronger sense of security when using Face ID.

From a developer standpoint, iPhone X includes changes in many aspects (covered here). All of these changes require integration of new APIs, rehash of layout (specifically considering the notch), and lots of testing. The integration of Face ID as the replacement for touch ID does not seem to be overly complex as they are using similar APIs (Source). The intricacies of the user flows that are all required include: safely disabling touch ID (see below), ensuring that users can reliably authenticate and that transactions aren’t approved accidentally just because the user is, well, looking at the screen. Let’s also keep in mind, developers have no time to conduct this testing: iPhone X adoption is happening (Source), and applications have to be ready.

Perfecto Automates Face ID Flows for iPhone X
Figure 1:Express app on iPhone X allows Touch ID

In order to facilitate interactive and automated testing of Face ID, Perfecto integrated Face ID APIs into the different interfaces of its testing solution. Relevant responses and error codes can be controlled via the script. Here’s a code sample describing how to automate Face ID flows in Java. Note: The samples contains preliminary API information.

//========================== Face ID  ===============================
// PerfectoUtils.setFaceIDState(driver,, PerfectoUtils.FaceIDErrorCode.userCancel);

public static enum FaceIDErrorCode {authFailed,
public static enum FaceIDState {success, fail};

public static void setFaceIDState(RemoteWebDriver driver, FaceIDState resultAuth, FaceIDErrorCode code) {
    Map<String, Object> params = new HashMap<>();

    if (null!= code)
        params.put("errorType", translateFaceIDStateErrorCodeToName(code));
    params.put("resultAuth", translateFaceIDStateToName(resultAuth));
    driver.executeScript("mobile:faceID:set", params);
private static String translateFaceIDStateErrorCodeToName(FaceIDErrorCode code){
    if (null == code) return "";
    String codeString =;
    return codeString;
private static String translateFaceIDStateToName(FaceIDState state){
    if (null == state) return "";
    String stateString =;
    return stateString;

Perfecto Automates Face ID
Figure 2: iPhone X with Face ID set to 'authFailed' in Perfecto lab

As Face ID will become a reality across all iOS devices, testing of user flows will become a necessary part of the test coverage. As the number of test cases increase, the coverage matrix will mandate automation and devices it needs to be tested on will simply overwhelm any manual testing approach. Now there is a way to do this, with Perfecto.