【问题标题】:Is it possible to automate touch ID or face ID using xcuitest in simulator?是否可以在模拟器中使用 xcuitest 自动化触摸 ID 或面部 ID?
【发布时间】:2019-05-02 11:54:55
【问题描述】:

有没有办法在模拟器中使用 xcuitest 框架来自动化面部 ID 或 Touch ID。手动我可以执行注册人脸/触摸 id 并执行匹配或不匹配的场景。但是我想知道它是否可以自动化?

【问题讨论】:

标签: ios xcuitest


【解决方案1】:

鉴于 Kane Cheshire 的 this post,可以通过发送如下所示的 Darwin 通知来自动化用于单元测试的 touch ID 和 face ID:

+ (void)enrolled {
  int token;
  notify_register_check("com.apple.BiometricKit.enrollmentChanged", &token);
  notify_set_state(token, 1);
  notify_post("com.apple.BiometricKit.enrollmentChanged");
}

但仅在 Objective-C 中,因此您可能需要使用桥接头。

在 Gitub 上从他的demo 导入文件Biometrics.mBiometrics.h,您将能够从您的XCTestCase 调用Biometrics.enrolled()

【讨论】:

  • 根据github.com/facebook/WebDriverAgent/issues/26,应该可以模拟与notify_post("com.apple.BiometricKit_Sim.fingerTouch.match")的匹配和与notify_post("com.apple.BiometricKit_Sim.fingerTouch.nomatch")的不匹配。
  • 是的,在我链接的库中使用;)
  • 哇。非常感谢 Axel 的指导。这篇文章看起来确实令人印象深刻。
  • 帖子中的链接已损坏
  • 在这里找到它:medium.com/kinandcartacreated/…
【解决方案2】:

或者,如果 Touch/FaceId 阻止了您的 XCUITesting,我建议您进行如下简单检查以禁用 Touch/faceId

guard CommandLine.isRunningUITests else {
    return true
}
extension CommandLine {
    static var isRunningUITests:Bool {
        return CommandLine.arguments.contains("--uitesting")
    }
}

您可以像下面这样轻松传递LaunchArguments

XCUIApplication().launchArguments.append("--uitesting")

【讨论】:

    猜你喜欢
    • 2016-07-19
    • 1970-01-01
    • 2011-01-06
    • 2013-06-18
    • 2014-10-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多