我有一个XCTest UI测试,其中两个设备使用CallKit建立呼叫。当来电到达被叫方时,将显示CallKit屏幕。他接受呼叫后,将显示主测试应用程序,并显示CallKit屏幕背景。这是默认行为。
是否有任何方法可以切换回CallKit屏幕?它不一定需要是XCTest方法,它可以是将由测试包调用的常规SDK代码。
我尝试记录打开多任务视图并切换到CallKit的过程,这是结果:
let app = XCUIApplication()
app.children(matching: .window).element(boundBy: 0).children(matching: .other).element.children(matching: .other).element.children(matching: .other).element.tap()
app.otherElements["com.apple.InCallService"].tap()
但是当运行记录的代码时,测试失败并显示以下错误:
Assertion Failure: Failed to get matching snapshot: No matches found for Elements matching predicate '"com.apple.InCallService" IN identifiers' from input
我从没做过,但是您可以尝试使用XCUIApplication(bundleIdentifier: "com.apple.mobilephone").launch()
切换回通话。