UI 测试上的调用按钮? [英] Call button on UI Testing?

查看:36
本文介绍了UI 测试上的调用按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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?

我的代码中有这个:

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 在电话呼叫系统对话框的情况下不起作用.电话对话由 Springboard 处理,而不是您的应用.

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 允许您访问 Springboard,因此您可以通过执行以下操作点击呼叫"按钮:

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

}

这篇关于UI 测试上的调用按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆