[英]Is it possible to automate touch ID or face ID using xcuitest in simulator?
Is there a way to automate face ID or Touch ID using xcuitest framework in simulator.有没有办法在模拟器中使用 xcuitest 框架来自动化面部 ID 或触控 ID。 Manually I can perform enrolling face/touch id and perform matching or non-matching scenarios.我可以手动执行注册人脸/触摸 ID 并执行匹配或不匹配的场景。 However I would like to know if it can be automated?但是我想知道它是否可以自动化?
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 :鉴于 Kane Cheshire 的这篇文章,可以通过发送如下所示的 Darwin 通知来自动化用于单元测试的触摸 ID 和面部 ID:
+ (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.仅在 Objective-C 中,因此您可能需要使用桥接头。
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
.从他在 Gitub 上的演示中导入文件Biometrics.m
和Biometrics.h
,您将能够从您的XCTestCase
调用Biometrics.enrolled()
。
Alternatively, if the Touch/FaceId is blocking your XCUITesting, I suggest, you put a simple check like the below to disable the Touch/faceId或者,如果 Touch/FaceId 阻止了您的 XCUITesting,我建议您进行如下简单检查以禁用 Touch/faceId
guard CommandLine.isRunningUITests else {
return true
}
extension CommandLine {
static var isRunningUITests:Bool {
return CommandLine.arguments.contains("--uitesting")
}
}
You can easily pass LaunchArguments
like below您可以轻松传递LaunchArguments
如下所示
XCUIApplication().launchArguments.append("--uitesting")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.