简体   繁体   English

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

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

I have a XCTest UI test where two devices establish a call using CallKit.我有一个 XCTest UI 测试,其中两个设备使用 CallKit 建立呼叫。 The CallKit screen is presented when the incoming call reaches the callee.当来电到达被叫方时,会显示 CallKit 屏幕。 Once he accepts the call, the main test app is presented and CallKit screen is backgrounded.一旦他接听电话,就会显示主测试应用程序,并且 CallKit 屏幕将变为背景。 This is the default behavior.这是默认行为。

Is there any way to switch back to the CallKit screen ?有没有办法切换回 CallKit 屏幕? It doesn't necessarily need to be a XCTest method, it could be regular SDK code that will just be called by the testing bundle.它不一定需要是 XCTest 方法,它可以是仅由测试包调用的常规 SDK 代码。

I tried recording the process of opening multitasking view and switching to CallKit and this is the result:我尝试记录打开多任务视图并切换到 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()

But when the recorded code is run, the test fails with following error:但是当运行记录的代码时,测试失败并出现以下错误:

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

Try to activate this screen by尝试通过以下方式激活此屏幕

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

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

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

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