0

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

Alfredo Luco G
  • 876
  • 7
  • 18

1 Answers1

4

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

}
joern
  • 27,354
  • 7
  • 90
  • 105
  • Hi @joern, I 've tried to call the interruption Monitor but It couldn't be called. Do u have any idea about the reason of that? – Alfredo Luco G Sep 25 '17 at 12:22
  • Have you added the monitor at the beginning of your test before tapping the phone button? And are you calling `app.tap()` right after adding the monitor? – joern Sep 25 '17 at 12:29
  • above I put my code for testing. However, it still not working. Do u have the reason why? – Alfredo Luco G Sep 25 '17 at 12:44
  • You are right. The Monitor does not work in this case. It just worked in my case because of some weird coincidence ;-) I rewrote the answer to make it work. – joern Sep 25 '17 at 13:18