问题
Is there a way to automate face ID or Touch ID using xcuitest framework in simulator. Manually I can perform enrolling face/touch id and perform matching or non-matching scenarios. However I would like to know if it can be automated?
回答1:
Given this post by Kane Cheshire it is possible to automate touch ID and face ID for unit testing by sending a Darwin notification like so :
+ (void)enrolled {
int token;
notify_register_check("com.apple.BiometricKit.enrollmentChanged", &token);
notify_set_state(token, 1);
notify_post("com.apple.BiometricKit.enrollmentChanged");
}
Only in Objective-C though, so you may need to use a bridging header.
Import the files Biometrics.m and Biometrics.h from his demo on Gitub and you will be able to call Biometrics.enrolled()
from your XCTestCase
.
来源:https://stackoverflow.com/questions/53555625/is-it-possible-to-automate-touch-id-or-face-id-using-xcuitest-in-simulator