我正在使用本机工具编写自动UI测试。在一个流程上,有一个指纹认证。我如何通过它,前进到下一个屏幕?
发布于 2017-10-06 06:15:21
你不能在UITest中伪造指纹。要通过身份验证并测试应用程序中被TouchID提示屏蔽的部分,可以在未启用TouchID的设备上运行测试。或者在模拟器上运行它(不启用TouchID)。
当TouchID未启用时,操作系统会向您询问设备的密码。您可以输入密码并通过身份验证。在模拟器上运行测试时,可以输入任何密码。总会过去的。
下面是一个通过输入密码通过身份验证的示例测试:
func testExample() {
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let app = XCUIApplication()
app.launch()
// this causes the authentication prompt to be displayed
app.buttons["Press Me!"].tap()
let passcodeInput = springboard.secureTextFields["Passcode field"]
passcodeInput.tap()
passcodeInput.typeText("abc\r")
// continue test
....
}https://stackoverflow.com/questions/46573880
复制相似问题