繁体   English   中英

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

[英]Open CallKit screen from an active call in XCTest UI test

我有一个 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()切换回呼叫。

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

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM