UI 测试中的呼叫按钮?

Call button on UI Testing?

我想知道是否可以从 tel 的方案中点击呼叫按钮(例如 tel//555555555)。因为如果我触摸通话按钮,我会收到一条提醒,提示我需要确认通话或取消通话。可能吗?

我的代码中有这个:

addUIInterruptionMonitor(withDescription: "Phone Dialog") { (alert) -> Bool in
        let button = alert.buttons["Llamar"]
        if button.exists {
            button.tap()
            return true
        }
        return false
    }
    app.tap()
    XCTAssert(app.buttons["call_button"].exists, "No se encuentra el boton de llamar")
    app.buttons["call_button"].tap()
    sleep(2)

有什么想法吗? 问候

UIInteractionMonitor 在 phone 调用系统对话框的情况下不起作用。 phone 调用对话框由 Springboard 而不是您的应用程序处理。

Xcode 9 允许您访问 Springboard,因此您可以点击 "Call" 按钮,方法是:

func testPhoneCall() {
    let app = XCUIApplication()
    let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")

    app.launch()
    app.buttons["call_button"].tap()

    // tap on the call button
    springboard.buttons["Llamar"].tap()

}