I am trying to do UI testing for making a phone call and receiving call but the test case is failing But I tried all XCUIElementTypeQueryProvider still is Not working.
func testPhoneCall() {
let Button = app.buttons["Call"]
XCTAssertTrue(Button.exists)
Button.tap()
sleep(2)
let cancelButton = app.alerts["Cancel"]
XCTAssertTrue(cancelButton.exists)
cancelButton.tap()
sleep(2)
let callButton = app.popUpButtons["Call"]
XCTAssertTrue(callButton.exists)
callButton.tap()
sleep(5)
}
This is the code what I tried But when I try to run this test case it is failing
@IBAction func callButtonClicked(_ sender: Any) {
callNumber(phoneNumber:"")
}
private func callNumber(phoneNumber:String) {
if let phoneCallURL = URL(string: "telprompt://\(+9535965654)") {
let application:UIApplication = UIApplication.shared
if (application.canOpenURL(phoneCallURL)) {
application.open(phoneCallURL, options: [:], completionHandler: nil)
}
}
}
This is my code which I wrote in view controller. can any one help me to write UItestcase for this code? Thank you