从XCTest UI测试中的活动呼叫打开CallKit屏幕

时间:2020-03-13 13:01:25

标签: ios xcode call xcuitest

我有一个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

2 个答案:

答案 0 :(得分:0)

我从没做过,但是您可以尝试使用XCUIApplication(bundleIdentifier: "com.apple.mobilephone").launch()切换回通话。

答案 1 :(得分:0)

尝试通过以下方式激活此屏幕

XCUIApplication(bundleIdentifier: "com.apple.InCallService").activate()

XCUIApplication(bundleIdentifier: "com.apple.springboard").activate()