Call button on UI Testing?

旧城冷巷雨未停 提交于 2019-12-11 14:17:32

问题


I was wondering if it's possible to tap call button from tel's scheme (e.g tel//555555555). Because if I touch call button I'll have an alert that I need to confirm my call or cancel it. Is it possible?

I have this on my code:

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)

Any Idea? Regards


回答1:


The UIInteractionMonitor does not work in the case of the phone call system dialog. The phone call dialog is handled by the Springboard and not your app.

Xcode 9 allows you access to the Springboard so you can tap on the "Call" button by doing this:

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()

}


来源:https://stackoverflow.com/questions/46322758/call-button-on-ui-testing

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!